diff options
author | Matěj Cepl <mcepl@cepl.eu> | 2019-02-19 12:40:44 +0100 |
---|---|---|
committer | Matěj Cepl <mcepl@cepl.eu> | 2019-02-19 13:25:15 +0100 |
commit | 03175389fac28aa877740d8d1099ca0da4ba6a9d (patch) | |
tree | d55e5c0d1a2842709aed664168165d56a2013d33 | |
parent | 5a689be2feeb3274aed258f49f7b3d6f6c10d995 (diff) | |
download | dlp_check_version_PyPI-03175389fac28aa877740d8d1099ca0da4ba6a9d.tar.gz |
Take another possible configuration file.
-rwxr-xr-x | dlpcvp.py | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1,6 +1,4 @@ #!/usr/bin/python3 -# Requires: python3-rpm - import argparse import configparser import json @@ -22,7 +20,8 @@ PyPI_base = "https://pypi.org/pypi/{}/json" # https://github.com/openSUSE/open-build-service/blob/master/docs/api/api/api.txt # https://build.opensuse.org/apidocs/index OBS_base = "https://api.opensuse.org" -ConfigRC = os.path.expanduser('~/.config/osc/oscrc') +ConfigRC = [os.path.expanduser('~/.oscrc'), + os.path.expanduser('~/.config/osc/oscrc')] CUTCHARS = len('python-') config = configparser.ConfigParser() @@ -105,12 +104,11 @@ def update_etags(con: sqlite3.Connection, pkg: str, e_suse_name: Optional[str], def parse_spec(spec_file: str, pkg: str) -> LooseVersion: - # rpm library generates awful lot of nonsensical goo on stderr if isinstance(spec_file, bytes): spec_file = spec_file.decode() rest_of_line = '' - for line in spec_file.split('\n'): + for line in spec_file.splitlines(): if line.startswith('Version:'): rest_of_line = line[len('Version:'):].strip() break @@ -119,7 +117,8 @@ def parse_spec(spec_file: str, pkg: str) -> LooseVersion: def get_spec_name(req: Request, pkg: str, etag: str = None) -> Optional[str]: - # Acquire version from the listing of the project directory + """Acquire version from the listing of the project directory. + """ spec_files = [] if etag is not None: @@ -221,8 +220,8 @@ def main(prj): db_name = os.path.split(os.path.basename(sys.argv[0]))[0] + ".db" with sqlite3.connect(db_name) as conn: if not conn.execute(TB_EXISTS).fetchone(): - conn.execute(TB_CREATE) - conn.execute(TB_CREATE_IDX) + conn.execute(TB_CREATE) + conn.execute(TB_CREATE_IDX) for pkg in suse_packages(prj): log.debug(f'pkg = {pkg}') |