Skip to content

Commit

Permalink
Applied latest Black
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 17, 2020
1 parent 1a6105c commit 7aeb51e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 9 deletions.
15 changes: 12 additions & 3 deletions github_to_sqlite/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,10 @@ def stargazers(db_path, repos, auth):
help="Path to auth.json token file",
)
@click.option(
"-r", "--repo", multiple=True, help="Just fetch these repos",
"-r",
"--repo",
multiple=True,
help="Just fetch these repos",
)
@click.option(
"--load",
Expand Down Expand Up @@ -349,7 +352,10 @@ def stop_when(commit):
help="Path to auth.json token file",
)
@click.option(
"-v", "--verbose", is_flag=True, help="Verbose output",
"-v",
"--verbose",
is_flag=True,
help="Verbose output",
)
def scrape_dependents(db_path, repos, auth, verbose):
"Scrape dependents for specified repos"
Expand Down Expand Up @@ -411,7 +417,10 @@ def scrape_dependents(db_path, repos, auth, verbose):
help="Path to auth.json token file",
)
@click.option(
"-f", "--fetch", is_flag=True, help="Fetch the image data into a BLOB column",
"-f",
"--fetch",
is_flag=True,
help="Fetch the image data into a BLOB column",
)
def emojis(db_path, auth, fetch):
"Fetch GitHub supported emojis"
Expand Down
39 changes: 33 additions & 6 deletions github_to_sqlite/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ def save_releases(db, releases, repo_id=None):
db["assets"].upsert_all(
assets,
pk="id",
foreign_keys=[("uploader", "users", "id"), ("release", "releases", "id"),],
foreign_keys=[
("uploader", "users", "id"),
("release", "releases", "id"),
],
alter=True,
)

Expand All @@ -468,14 +471,22 @@ def save_contributors(db, contributors, repo_id):
def save_tags(db, tags, repo_id):
if not db["tags"].exists():
db["tags"].create(
{"repo": int, "name": str, "sha": str,},
{
"repo": int,
"name": str,
"sha": str,
},
pk=("repo", "name"),
foreign_keys=[("repo", "repos", "id")],
)

db["tags"].insert_all(
(
{"repo": repo_id, "name": tag["name"], "sha": tag["commit"]["sha"],}
{
"repo": repo_id,
"name": tag["name"],
"sha": tag["commit"]["sha"],
}
for tag in tags
),
replace=True,
Expand All @@ -492,7 +503,14 @@ def save_commits(db, commits, repo_id=None):
]

if not db["raw_authors"].exists():
db["raw_authors"].create({"id": str, "name": str, "email": str,}, pk="id")
db["raw_authors"].create(
{
"id": str,
"name": str,
"email": str,
},
pk="id",
)

if not db["commits"].exists():
# We explicitly create the table because otherwise we may create it
Expand Down Expand Up @@ -530,7 +548,9 @@ def save_commits(db, commits, repo_id=None):
save_user(db, commit["committer"]) if commit["committer"] else None
)
db["commits"].insert(
commit_to_insert, alter=True, replace=True,
commit_to_insert,
alter=True,
replace=True,
)


Expand All @@ -539,7 +559,14 @@ def save_commit_author(db, raw_author):
email = raw_author.get("email")
return (
db["raw_authors"]
.insert({"name": name, "email": email,}, hash_id="id", replace=True)
.insert(
{
"name": name,
"email": email,
},
hash_id="id",
replace=True,
)
.last_pk
)

Expand Down

0 comments on commit 7aeb51e

Please sign in to comment.