]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
build-integration-branch: change to be pep8 compliant 37700/head
authorKefu Chai <kchai@redhat.com>
Sat, 17 Oct 2020 03:24:22 +0000 (11:24 +0800)
committerKefu Chai <kchai@redhat.com>
Sat, 17 Oct 2020 03:24:22 +0000 (11:24 +0800)
Signed-off-by: Kefu Chai <kchai@redhat.com>
src/script/build-integration-branch

index 511a950d44b476731fae4a276a4282057345642d..e0cf9f4544f6d36c11ed71b41d989bf2045afc34 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/env python3
 
 """
-Builds integration branches. Something similar to 
+Builds integration branches. Something similar to
   $ git checkout -b branch-name
   $ for b in $(get-branches-from-github) ; do
   >   git pull b
@@ -19,56 +19,50 @@ Options:
   --no-date   Don't add `{postfix}` to the branch name.
 """
 
-from __future__ import print_function
-
 import json
 import os
 import requests
-from subprocess import call, check_output
 import sys
 import time
-try:
-    from urllib.parse import urljoin
-except:
-    from urlparse import urljoin
+
+from subprocess import call, check_output
+from urllib.parse import urljoin
 
 TIME_FORMAT = '%Y-%m-%d-%H%M'
 postfix = "-" + time.strftime(TIME_FORMAT, time.localtime())
 
-current_branch = check_output('git rev-parse --abbrev-ref HEAD', shell=True).strip().decode()
+current_branch = check_output('git rev-parse --abbrev-ref HEAD',
+                              shell=True).strip().decode()
 if current_branch in 'mimic nautilus octopus pacific'.split():
-  postfix += '-' + current_branch
-  print(f"Adding current branch name '-{current_branch}' as a postfix")
+    postfix += '-' + current_branch
+    print(f"Adding current branch name '-{current_branch}' as a postfix")
 
 repo = "ceph/ceph"
 
 try:
-  from docopt import docopt
-  arguments = docopt(__doc__.format(postfix=postfix))
-  label = arguments['<label>']
-  branch = label
-  if not arguments['--no-date']:
-      branch += postfix
+    from docopt import docopt
+    arguments = docopt(__doc__.format(postfix=postfix))
+    label = arguments['<label>']
+    branch = label
+    if not arguments['--no-date']:
+        branch += postfix
 except ImportError:
-  # Fallback without docopt.
-  label = sys.argv[1]
-  assert len(sys.argv) == 2
-  branch = label + postfix
+    # Fallback without docopt.
+    label = sys.argv[1]
+    assert len(sys.argv) == 2
+    branch = label + postfix
 
 
-with open(os.environ['HOME'] + '/.github_token', 'r') as myfile:
+with open(os.path.expanduser('~/.github_token')) as myfile:
     token = myfile.readline().strip()
 
 # get prs
-baseurl = urljoin('https://api.github.com', (
-                      'repos/{repo}/issues?labels={label}'
-                      '&sort=created'
-                      '&direction=asc'
-                    )
-                 )
-url = baseurl.format(
-    label=label,
-    repo=repo)
+baseurl = urljoin('https://api.github.com',
+                  ('repos/{repo}/issues?labels={label}'
+                   '&sort=created'
+                   '&direction=asc'))
+url = baseurl.format(label=label,
+                     repo=repo)
 r = requests.get(url,
                  headers={'Authorization': 'token %s' % token})
 assert(r.ok)