Organize Python code in a source directory and a bin directory
This commit is contained in:
Родитель
070ddc979b
Коммит
a5b3654500
|
@ -0,0 +1,36 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import argparse
|
||||
import os
|
||||
|
||||
from microannotate import generator
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"repository_dir", help="Path to the input repository", action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"repository_out_dir", help="Path to the output repository", action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rev-start",
|
||||
help="Which revision to start with (0 by default)",
|
||||
action="store",
|
||||
default="0",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rev-end",
|
||||
help="Which revision to end with (tip by default)",
|
||||
action="store",
|
||||
default="tip",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
repo_out_dir = os.path.realpath(args.repository_out_dir)
|
||||
|
||||
generator.generate(args.repository_dir, repo_out_dir, args.rev_start, args.rev_end)
|
|
@ -0,0 +1,22 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import argparse
|
||||
|
||||
from microannotate import viewer
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("repository_dir", help="Path to the repository", action="store")
|
||||
parser.add_argument(
|
||||
"path", help="Path to the file in the repository", action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"rev", help="Start annotating from this revision", action="store"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
viewer.html(args.repository_dir, args.rev, args.path)
|
|
@ -0,0 +1 @@
|
|||
# -*- coding: utf-8 -*-
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import collections
|
||||
|
||||
import utils
|
||||
from microannotate import utils
|
||||
|
||||
|
||||
class Commit(object):
|
|
@ -3,7 +3,6 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import argparse
|
||||
import concurrent.futures
|
||||
import itertools
|
||||
import os
|
||||
|
@ -13,7 +12,7 @@ import hglib
|
|||
import pygit2
|
||||
from tqdm import tqdm
|
||||
|
||||
import utils
|
||||
from microannotate import utils
|
||||
|
||||
|
||||
class Commit:
|
||||
|
@ -166,7 +165,7 @@ def get_revs(hg, rev_start=0, rev_end="tip"):
|
|||
return x.splitlines()
|
||||
|
||||
|
||||
def download_commits(repo_dir, repo_out_dir, rev_start=0, rev_end="tip"):
|
||||
def generate(repo_dir, repo_out_dir, rev_start=0, rev_end="tip"):
|
||||
if os.path.exists(repo_out_dir):
|
||||
repo = pygit2.Repository(repo_out_dir)
|
||||
last_commit_hash = utils.get_original_hash(repo, "HEAD")
|
||||
|
@ -208,30 +207,3 @@ def download_commits(repo_dir, repo_out_dir, rev_start=0, rev_end="tip"):
|
|||
convert(repo, commit)
|
||||
except Exception:
|
||||
f.write(f"{commit.node} - {commit.parents}\n")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"repository_dir", help="Path to the input repository", action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"repository_out_dir", help="Path to the output repository", action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rev-start",
|
||||
help="Which revision to start with (0 by default)",
|
||||
action="store",
|
||||
default="0",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--rev-end",
|
||||
help="Which revision to end with (tip by default)",
|
||||
action="store",
|
||||
default="tip",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
repo_out_dir = os.path.realpath(args.repository_out_dir)
|
||||
|
||||
download_commits(args.repository_dir, repo_out_dir, args.rev_start, args.rev_end)
|
|
@ -3,7 +3,6 @@
|
|||
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
# You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
import argparse
|
||||
import collections
|
||||
import os
|
||||
import random
|
||||
|
@ -12,11 +11,10 @@ import subprocess
|
|||
import hglib
|
||||
import pygit2
|
||||
|
||||
import annotatehelper
|
||||
import utils
|
||||
from microannotate import annotatehelper, utils
|
||||
|
||||
|
||||
def go(repository_dir, rev, path):
|
||||
def html(repository_dir, rev, path):
|
||||
repository_dir = os.path.realpath(repository_dir)
|
||||
|
||||
repo = pygit2.Repository(repository_dir)
|
||||
|
@ -102,18 +100,4 @@ def go(repository_dir, rev, path):
|
|||
</html>
|
||||
"""
|
||||
|
||||
print(html)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("repository_dir", help="Path to the repository", action="store")
|
||||
parser.add_argument(
|
||||
"path", help="Path to the file in the repository", action="store"
|
||||
)
|
||||
parser.add_argument(
|
||||
"rev", help="Start annotating from this revision", action="store"
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
go(args.repository_dir, args.rev, args.path)
|
||||
return html
|
2
setup.py
2
setup.py
|
@ -31,7 +31,7 @@ setup(
|
|||
packages=find_packages(exclude=["contrib", "docs", "tests"]),
|
||||
include_package_data=True,
|
||||
license="MPL2",
|
||||
scripts=["microannotate-generate.py", "microannotate.py"],
|
||||
scripts=["bin/microannotate-generate.py", "bin/microannotate-view.py"],
|
||||
classifiers=[
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3 :: Only",
|
||||
|
|
Загрузка…
Ссылка в новой задаче