Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
quiver-frontend-local
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Monitor
Service Desk
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
subugoe
OCR-D
quiver-frontend-local
Commits
22a76acf
Commit
22a76acf
authored
5 years ago
by
Konstantin Baierer
Browse files
Options
Downloads
Patches
Plain Diff
fetch pypi info, git remote url
parent
a7efae03
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
kwalitee/cli.py
+2
-9
2 additions, 9 deletions
kwalitee/cli.py
kwalitee/repo.py
+19
-13
19 additions, 13 deletions
kwalitee/repo.py
with
21 additions
and
22 deletions
kwalitee/cli.py
+
2
−
9
View file @
22a76acf
...
...
@@ -62,19 +62,12 @@ def pull_all(ctx):
'''
)
@pass_ctx
@click.option
(
'
-a
'
,
'
--full
'
,
help
=
"
Set all flags
"
,
is_flag
=
True
,
default
=
False
)
@click.option
(
'
-g
'
,
'
--git
'
,
help
=
"
Git stats
"
,
is_flag
=
True
,
default
=
False
)
@click.option
(
'
-p
'
,
'
--python
'
,
help
=
"
Python stats
"
,
is_flag
=
True
,
default
=
False
)
@click.option
(
'
-f
'
,
'
--files
'
,
help
=
"
Files
"
,
is_flag
=
True
,
default
=
False
)
def
generate_json
(
ctx
,
full
,
**
kwargs
):
def
generate_json
(
ctx
):
ret
=
[]
if
full
:
for
k
in
kwargs
:
kwargs
[
k
]
=
True
_check_cloned
(
ctx
)
for
repo
in
ctx
.
repos
:
LOG
.
info
(
"
# Assessing %s
"
%
repo
.
name
)
repo
.
clone
()
ret
.
append
(
repo
.
to_json
(
**
kwargs
))
ret
.
append
(
repo
.
to_json
())
# print('%s %s -> %s' % (repo.path.is_dir(), repo.url, repo.path))
print
(
json
.
dumps
(
ret
,
indent
=
4
,
sort_keys
=
True
))
This diff is collapsed.
Click to expand it.
kwalitee/repo.py
+
19
−
13
View file @
22a76acf
...
...
@@ -3,6 +3,7 @@ import json
from
subprocess
import
run
,
PIPE
from
shlex
import
split
as
X
from
ocrd_utils
import
pushd_popd
,
getLogger
import
requests
as
R
LOG
=
getLogger
(
'
kwalitee.repo
'
)
...
...
@@ -37,13 +38,17 @@ class Repo():
def
get_git_stats
(
self
):
ret
=
{}
LOG
.
info
(
"
Fetching git info
"
)
with
pushd_popd
(
self
.
path
):
ret
[
'
number_of_commits
'
]
=
self
.
_run
(
'
git rev-list HEAD --count
'
).
stdout
ret
[
'
last_commit
'
]
=
self
.
_run
(
r
'
git log -1 --format=%cd
'
).
stdout
ret
[
'
url
'
]
=
self
.
_run
(
'
git config --get remote.origin.url
'
).
stdout
ret
[
'
latest_tag
'
]
=
self
.
_run
(
'
git describe --abbrev=0 --tags
'
).
stdout
return
ret
def
get_file_contents
(
self
):
ret
=
{}
LOG
.
info
(
"
Getting file contents
"
)
with
pushd_popd
(
self
.
path
):
for
path
in
[
Path
(
x
)
for
x
in
[
'
ocrd-tool.json
'
,
'
Dockerfile
'
,
'
README.md
'
,
'
setup.py
'
]]:
if
path
.
is_file
():
...
...
@@ -60,25 +65,26 @@ class Repo():
ret
[
'
name
'
]
=
self
.
_run
(
'
python3 setup.py --name
'
).
stdout
ret
[
'
author
'
]
=
self
.
_run
(
'
python3 setup.py --author
'
).
stdout
ret
[
'
author-email
'
]
=
self
.
_run
(
'
python3 setup.py --author-email
'
).
stdout
LOG
.
info
(
"
Fetching pypi info
"
)
response
=
R
.
get
(
'
https://pypi.python.org/pypi/%s/json
'
%
ret
[
'
name
'
])
ret
[
'
pypi
'
]
=
json
.
loads
(
response
.
text
)
if
response
.
status_code
==
200
else
None
return
ret
def
to_json
(
self
,
git
=
True
,
python
=
True
,
files
=
True
):
def
to_json
(
self
):
desc
=
{}
desc
[
'
url
'
]
=
self
.
url
desc
[
'
org_plus_name
'
]
=
'
/
'
.
join
(
self
.
url
.
split
(
'
/
'
)[
-
2
:])
desc
[
'
name
'
]
=
self
.
name
if
files
:
desc
[
'
files
'
]
=
self
.
get_file_contents
()
if
desc
[
'
files
'
][
'
ocrd-tool.json
'
]:
desc
[
'
ocrd_tool
'
]
=
json
.
loads
(
desc
[
'
files
'
][
'
ocrd-tool.json
'
])
with
pushd_popd
(
self
.
path
):
desc
[
'
ocrd_tool_validate
'
]
=
self
.
_run
(
'
ocrd ocrd-tool ocrd-tool.json validate
'
).
stdout
else
:
desc
[
'
ocrd_tool
'
]
=
''
desc
[
'
ocrd_tool_validate
'
]
=
'
NO ocrd-tool.json
'
if
git
:
desc
[
'
git
'
]
=
self
.
get_git_stats
()
if
python
:
desc
[
'
files
'
]
=
self
.
get_file_contents
()
if
desc
[
'
files
'
][
'
ocrd-tool.json
'
]:
desc
[
'
ocrd_tool
'
]
=
json
.
loads
(
desc
[
'
files
'
][
'
ocrd-tool.json
'
])
with
pushd_popd
(
self
.
path
):
desc
[
'
ocrd_tool_validate
'
]
=
self
.
_run
(
'
ocrd ocrd-tool ocrd-tool.json validate
'
).
stdout
else
:
desc
[
'
ocrd_tool
'
]
=
''
desc
[
'
ocrd_tool_validate
'
]
=
'
NO ocrd-tool.json
'
desc
[
'
git
'
]
=
self
.
get_git_stats
()
if
desc
[
'
files
'
][
'
setup.py
'
]:
desc
[
'
python
'
]
=
self
.
get_python_info
()
return
desc
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment