#106 Use more f-strings.
Merged 5 years ago by pingou. Opened 5 years ago by qulogic.
qulogic/mdapi fstr  into  master

file modified
+8 -9
@@ -52,8 +52,8 @@ 

  

  

  DB_FOLDER = '/var/tmp'

- KOJI_REPO = 'https://kojipkgs.fedoraproject.org/repos/'

- PKGDB2_URL = 'https://admin.fedoraproject.org/pkgdb/'

+ KOJI_REPO = 'https://kojipkgs.fedoraproject.org/repos'

+ PKGDB2_URL = 'https://admin.fedoraproject.org/pkgdb'

  DL_SERVER = 'https://dl.fedoraproject.org'

  # Enforce, or not, checking the SSL certs

  PKGDB2_VERIFY = True
@@ -154,7 +154,7 @@ 

      ''' Return the list of Fedora branches corresponding to the given

      status.

      '''

-     url = PKGDB2_URL + f'api/collections?clt_status={status}'

+     url = f'{PKGDB2_URL}/api/collections?clt_status={status}'

      response = requests.get(url, verify=PKGDB2_VERIFY)

      response.raise_for_status()

      data = response.json()
@@ -313,9 +313,8 @@ 

          )

          publish(msg)

      except PublishReturned as e:

-         print(

-             f"Fedora Messaging broker rejected message {msg.id}: {e}", file=sys.stderr

-         )

+         print(f"Fedora Messaging broker rejected message {msg.id}: {e}",

+               file=sys.stderr)

      except ConnectionException as e:

          print(f"Error sending message {msg.id}: {e}", file=sys.stderr)

  
@@ -355,7 +354,7 @@ 

      the provided name.

      '''

      url, name = repo

-     repomd_url = url + '/repomd.xml'

+     repomd_url = f'{url}/repomd.xml'

      response = requests.get(repomd_url, verify=DL_VERIFY)

      if not response:

          print(f'{name.ljust(padding)} !! Failed to get {repomd_url!r} {response!r}')
@@ -388,7 +387,7 @@ 

          print(f'No sqlite database could be found in {url}')

  

      for filename, shasum, shatype in files:

-         repomd_url = url + '/' + filename

+         repomd_url = f'{url}/{filename}'

  

          # First, determine if the file has changed by comparing hash

          db = None
@@ -459,7 +458,7 @@ 

      repositories = []

      # Get the koji repo

      repositories.append(

-         (KOJI_REPO + 'rawhide/latest/x86_64/repodata', 'koji')

+         (f'{KOJI_REPO}/rawhide/latest/x86_64/repodata', 'koji')

      )

  

      # Get the development repos (rawhide + eventually Fn+1 branched)

file modified
+5 -5
@@ -80,7 +80,7 @@ 

              continue

  

          wrongdb = False

-         async with aiosqlite.connect(f'{dbfile}') as db:

+         async with aiosqlite.connect(dbfile) as db:

              if action:

                  # It is safe to format the query since the action does not come from the

                  # user.
@@ -91,7 +91,7 @@ 

                      pkg = [Packages(*item) for item in pkgc]

                      break

              elif srcname:

-                 async with db.execute(GET_PACKAGE_BY_SRC, (srcname+'-%',)) as cursor:

+                 async with db.execute(GET_PACKAGE_BY_SRC, (f'{srcname}-%',)) as cursor:

                      pkgc = await cursor.fetchall()

                  if pkgc:

                      srcname = re.escape(srcname)
@@ -128,7 +128,7 @@ 

          dbfile = f'{CONFIG["DB_FOLDER"]}/mdapi-{branch}{"-"+repotype if repotype else ""}'\

                   '-primary.sqlite'

  

-         async with aiosqlite.connect(f'{dbfile}') as db:

+         async with aiosqlite.connect(dbfile) as db:

              # Fill in some extra info

              # Basic infos, always present regardless of the version of the repo

              for datatype in ['conflicts',
@@ -174,7 +174,7 @@ 

      if not os.path.exists(dbfile):

          raise web.HTTPBadRequest()

  

-     async with aiosqlite.connect(f"{dbfile}") as db:

+     async with aiosqlite.connect(dbfile) as db:

          async with db.execute(GET_FILES, (pkg_id,)) as cursor:

              filelists = await cursor.fetchall()

  
@@ -195,7 +195,7 @@ 

      if not os.path.exists(dbfile):

          raise web.HTTPBadRequest()

  

-     async with aiosqlite.connect(f"{dbfile}") as db:

+     async with aiosqlite.connect(dbfile) as db:

          async with db.execute(GET_CHANGELOGS, (pkg_id,)) as cursor:

              changelogs = await cursor.fetchall()

  

no initial comment

rebased onto 43edbf7

5 years ago

Looks like this conflicts now :)

rebased onto 8cce7dc

5 years ago

1 new commit added

  • Remove some extraneous f-strings.
5 years ago

rebased onto bdc242e

5 years ago

Rebased and also removed some extra f-strings.

Looks good to me, thanks! :)

Pull-Request has been merged by pingou

5 years ago
Metadata