Skip to content

Commit

Permalink
python setup
Browse files Browse the repository at this point in the history
  • Loading branch information
SauravKanchan committed Apr 19, 2020
1 parent 3f4f81a commit a1be18a
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 120 deletions.
195 changes: 104 additions & 91 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
.heroku/*
.profile.d/*

# Created by https://www.gitignore.io/api/node,jetbrains+all
# Edit at https://www.gitignore.io/?templates=node,jetbrains+all

# Created by https://www.gitignore.io/api/venv,python,jetbrains+all
# Edit at https://www.gitignore.io/?templates=venv,python,jetbrains+all

### JetBrains+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
Expand Down Expand Up @@ -91,110 +92,122 @@ modules.xml
# Sonarlint plugin
.idea/sonarlint

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# Runtime data
pids
*.pid
*.seed
*.pid.lock
# C extensions
*.so

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/

# Coverage directory used by tools like istanbul
coverage
*.lcov
# Translations
*.mo
*.pot

# nyc test coverage
.nyc_output
# Scrapy stuff:
.scrapy

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Sphinx documentation
docs/_build/

# Bower dependency directory (https://bower.io/)
bower_components
# PyBuilder
target/

# node-waf configuration
.lock-wscript
# pyenv
.python-version

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# Dependency directories
node_modules/
jspm_packages/
# celery beat schedule file
celerybeat-schedule

# TypeScript v1 declaration files
typings/
# SageMath parsed files
*.sage.py

# TypeScript cache
*.tsbuildinfo
# Spyder project settings
.spyderproject
.spyproject

# Optional npm cache directory
.npm
# Rope project settings
.ropeproject

# Optional eslint cache
.eslintcache
# Mr Developer
.mr.developer.cfg
.project
.pydevproject

# Optional REPL history
.node_repl_history
# mkdocs documentation
/site

# Output of 'npm pack'
*.tgz
# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Yarn Integrity file
.yarn-integrity
# Pyre type checker
.pyre/

# dotenv environment variables file
### venv ###
# Virtualenv
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
pyvenv.cfg
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# next.js build output
.next

# nuxt.js build output
.nuxt

# rollup.js default build output
dist/

# Uncomment the public line if your project uses Gatsby
# https://nextjs.org/blog/next-9-1#public-directory-support
# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
# public

# Storybook build outputs
.out
.storybook-out

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# Temporary folders
tmp/
temp/

# End of https://www.gitignore.io/api/node,jetbrains+all
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
pip-selfcheck.json

# End of https://www.gitignore.io/api/venv,python,jetbrains+all
29 changes: 29 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import base64, requests, json


def push_to_github(filename, repo, branch, token):
url = "https://api.github.com/repos/" + repo + "/contents/" + filename
base64content = base64.b64encode(bytes('asdfasdf', 'utf-8'))
data = requests.get(url + '?ref=' + branch, headers={"Authorization": "token " + token}).json()
sha = data['sha']
if base64content.decode('utf-8') + "\n" != data['content']:
message = json.dumps({"message": "update",
"branch": branch,
"content": base64content.decode("utf-8"),
"sha": sha
})

resp = requests.put(url, data=message,
headers={"Content-Type": "application/json", "Authorization": "token " + token})

print(resp)
else:
print("nothing to update")


token = ""
filename = "top-headlines/category/health/in.json"
repo = "SauravKanchan/NewsAPI"
branch = "master"

push_to_github(filename, repo, branch, token)
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
certifi==2020.4.5.1
chardet==3.0.4
idna==2.9
requests==2.23.0
urllib3==1.25.9
28 changes: 0 additions & 28 deletions test.py

This file was deleted.

Loading

0 comments on commit a1be18a

Please sign in to comment.