commit:     cf01cb49e14730c2323da4ef9f8093935ef93fb9
Author:     Alfred Wingate <parona <AT> protonmail <DOT> com>
AuthorDate: Thu Oct  5 23:04:53 2023 +0000
Commit:     Sebastian Pipping <sping <AT> gentoo <DOT> org>
CommitDate: Thu Oct  5 23:04:53 2023 +0000
URL:        https://gitweb.gentoo.org/proj/elogv.git/commit/?id=cf01cb49

Reformat with black

Signed-off-by: Alfred Wingate <parona <AT> protonmail.com>

 elogv    | 265 +++++++++++++++++++++++++++++++++++++--------------------------
 setup.py | 122 +++++++++++++++--------------
 2 files changed, 215 insertions(+), 172 deletions(-)

diff --git a/elogv b/elogv
index 94d466a..4b4f85f 100755
--- a/elogv
+++ b/elogv
@@ -37,31 +37,39 @@ import lzma
 import signal
 
 _LOCALE_CATEGORY_PAIRS = (
-               (locale.LC_COLLATE, 'LC_COLLATE'),
-               (locale.LC_CTYPE, 'LC_CTYPE'),
-               (locale.LC_MESSAGES, 'LC_MESSAGES'),
-               (locale.LC_MONETARY, 'LC_MONETARY'),
-               (locale.LC_NUMERIC, 'LC_NUMERIC'),
-               (locale.LC_TIME, 'LC_TIME'),
-
-               (locale.LC_ALL, 'LC_ALL'),
+    (locale.LC_COLLATE, "LC_COLLATE"),
+    (locale.LC_CTYPE, "LC_CTYPE"),
+    (locale.LC_MESSAGES, "LC_MESSAGES"),
+    (locale.LC_MONETARY, "LC_MONETARY"),
+    (locale.LC_NUMERIC, "LC_NUMERIC"),
+    (locale.LC_TIME, "LC_TIME"),
+    (locale.LC_ALL, "LC_ALL"),
 )
 
 
 def report_bad_locale(variable, value):
-    py_version = '%s.%s.%s' % sys.version_info[:3]
+    py_version = "%s.%s.%s" % sys.version_info[:3]
     print('ERROR: Locale "%s" does not seem to be supported.' % value, 
file=sys.stderr)
     if value not in locale.locale_alias:
-        print('  Note: Locale "%s" is not a known alias to Python %s (check 
locale.locale_alias).' % (value, py_version), file=sys.stderr)
-    if not ('.' in value or '@' in value):
-        print('  Hint: Try specifying the encoding (e.g. %s=%s.UTF-8).' % 
(variable, value), file=sys.stderr)
+        print(
+            '  Note: Locale "%s" is not a known alias to Python %s (check 
locale.locale_alias).'
+            % (value, py_version),
+            file=sys.stderr,
+        )
+    if not ("." in value or "@" in value):
+        print(
+            "  Hint: Try specifying the encoding (e.g. %s=%s.UTF-8)."
+            % (variable, value),
+            file=sys.stderr,
+        )
+
 
 reported_bad_locales = set()
 
 
 # Enable support for user locale
 try:
-    locale.setlocale(locale.LC_ALL, '')
+    locale.setlocale(locale.LC_ALL, "")
 except locale.Error:
     # Find guilty value and variable
     for category, variable in _LOCALE_CATEGORY_PAIRS:
@@ -95,11 +103,12 @@ if reported_bad_locales:
 
 
 # Setup gettext.
-gettext.textdomain('elogv')
+gettext.textdomain("elogv")
 _ = gettext.gettext
 
 # This text is used on the in-line help
-helptext = _("""
+helptext = _(
+    """
 Elogv is a portage elog viewer based on curses and python,
 you can use these keys to control the behavior of the program:
 
@@ -127,7 +136,8 @@ you can use these keys to control the behavior of the 
program:
  - / -> starts a search prompt, write a string and will be showed the next
         package that contains your string, use ESC to exit
  - q -> quit
-""")
+"""
+)
 
 (normal, selected, einfo, elog, ewarn, eerror) = range(6)
 (PATH, CAT, PN, DATE, CLASS) = range(5)
@@ -137,6 +147,7 @@ class_char = "*"
 list_format = "%s/%s - %s"
 date_format = "%x"
 
+
 # Exceptions classes
 class TermTooSmall(Exception):
     """Terminal too small."""
@@ -165,11 +176,11 @@ def date2str(d):
     b = d.strftime(date_format)
 
     for encoding in (
-            locale.getlocale(locale.LC_TIME)[1],
-            locale.getlocale()[1],
-            sys.getdefaultencoding(),
-            'utf-8',
-            ):
+        locale.getlocale(locale.LC_TIME)[1],
+        locale.getlocale()[1],
+        sys.getdefaultencoding(),
+        "utf-8",
+    ):
         if encoding is None:
             continue
 
@@ -182,24 +193,25 @@ def date2str(d):
         except UnicodeDecodeError:
             pass
     else:
-        raise ValueError('Cannot decode byte stream')
+        raise ValueError("Cannot decode byte stream")
 
     try:
         if not isinstance(b, str):
-            b = u.encode('ascii')
+            b = u.encode("ascii")
         else:
             b = u
     except UnicodeEncodeError:
         # Prevent crash locales like ja_JP.UTF-8, e.g. "2014年10月24日"
         # https://bugs.gentoo.org/show_bug.cgi?id=464962
-        b = u.encode('ascii', errors='replace')
+        b = u.encode("ascii", errors="replace")
 
     return b
 
+
 # Main class (called with curses.wrapper later)
 class ElogViewer:
     def __init__(self, screen):
-        #curses.curs_set(0)
+        # curses.curs_set(0)
         self.screen = screen
 
         # Our color pairs
@@ -214,20 +226,20 @@ class ElogViewer:
             pass
 
         # This attributes are used to manage the scrolling of the list
-        # of files    
+        # of files
         self.pposy = 0
         self.usel = 0
 
         # Method used to order the list: use DATE for order by date, CAT to
         # order by category name, PN to order by package name, CLASS to order
         # by class second value set if the list should be reversed (True o 
False)
-        self.sort_method = [ DATE, False]
+        self.sort_method = [DATE, False]
 
         # Initialize screen
         self.init_screen()
 
         c = self.screen.getch()
-        while c not in ( ord("q"), curses.ascii.ESC):
+        while c not in (ord("q"), curses.ascii.ESC):
             ## Scrolling keys ##
             if c in (curses.KEY_DOWN, ord("j")):
                 self.change_usel(1)
@@ -237,12 +249,12 @@ class ElogViewer:
 
             elif c in (curses.KEY_NPAGE, ord("f")):
                 self.change_usel(10)
-                
+
             elif c in (curses.KEY_PPAGE, ord("b")):
                 self.change_usel(-10)
 
             elif c in (curses.KEY_END, ord("G")):
-                self.change_usel(len(self.packages)-1, False)
+                self.change_usel(len(self.packages) - 1, False)
 
             elif c in (curses.KEY_HOME, ord("g")):
                 self.change_usel(0, False)
@@ -317,12 +329,12 @@ class ElogViewer:
 
             elif c == ord("/"):
                 word = ""
-                self.screen.move(self.height-1,2)
+                self.screen.move(self.height - 1, 2)
                 self.screen.addstr("/")
                 subc = self.screen.getch()
                 while subc != curses.ascii.ESC:
                     if subc == ord("\n"):
-                        self.search(word,1)
+                        self.search(word, 1)
                     elif subc == curses.ascii.BS:
                         word = word[:-1]
                         self.screen.delch()
@@ -330,10 +342,10 @@ class ElogViewer:
                     elif curses.ascii.isalpha(subc):
                         word += chr(subc)
                         self.screen.addstr(chr(subc))
-                        self.search(word)  
+                        self.search(word)
                     subc = self.screen.getch()
-                
self.screen.hline(self.height-1,2,curses.ACS_HLINE,(len(word)+1))
-                self.screen.addstr(self.height-2,2," "*20)
+                self.screen.hline(self.height - 1, 2, curses.ACS_HLINE, 
(len(word) + 1))
+                self.screen.addstr(self.height - 2, 2, " " * 20)
 
             # Get another key from the user
             c = self.screen.getch()
@@ -351,14 +363,15 @@ class ElogViewer:
 
         # Screen Look&Feel
         self.screen.border()
-        self.screen.hline(self.height//2,1, "_", self.width-2)
+        self.screen.hline(self.height // 2, 1, "_", self.width - 2)
         m = _(" Press F1 or h to show the help screen ")
-        self.screen.addstr(self.height-1, self.width-len(m)-1, m)
+        self.screen.addstr(self.height - 1, self.width - len(m) - 1, m)
         self.screen.refresh()
 
         # Initialize log file window
-        self.log_win = curses.newwin(self.height//2-2, self.width-2,
-                                     self.height//2+1, 1)
+        self.log_win = curses.newwin(
+            self.height // 2 - 2, self.width - 2, self.height // 2 + 1, 1
+        )
 
         # Draw other window of the screen
         self.fill_file_pad()
@@ -367,31 +380,37 @@ class ElogViewer:
         self.logf_wrap = self.wrap_logf_lines()
         self.show_log()
 
-    def change_usel(self,n,relative=True):
+    def change_usel(self, n, relative=True):
         prev_usel = self.usel
         if not relative:
             self.usel = n
-        elif n < 0 and self.usel+n < 0:
+        elif n < 0 and self.usel + n < 0:
             self.usel = 0
-        elif n > 0 and self.usel+n > len(self.packages)-1:
-            self.usel = len(self.packages)-1
+        elif n > 0 and self.usel + n > len(self.packages) - 1:
+            self.usel = len(self.packages) - 1
         else:
             self.usel += n
 
         prev_pkg = self.packages[prev_usel]
         pkg = self.packages[self.usel]
-        self.file_pad.addstr(prev_usel,1,
-                                 class_char,
-                                 curses.A_BOLD + 
curses.color_pair(prev_pkg[CLASS]))
-        self.file_pad.addstr(prev_usel,3,
-                                 list_format % (prev_pkg[CAT], prev_pkg[PN], 
date2str(prev_pkg[DATE]) ),
-                                 curses.color_pair(normal))
-        self.file_pad.addstr(self.usel,1,
-                                 class_char,
-                                 curses.A_BOLD + curses.color_pair(pkg[CLASS]))
-        self.file_pad.addstr(self.usel,3,
-                                 list_format % (pkg[CAT], pkg[PN], 
date2str(pkg[DATE]) ),
-                                 curses.color_pair(selected))
+        self.file_pad.addstr(
+            prev_usel, 1, class_char, curses.A_BOLD + 
curses.color_pair(prev_pkg[CLASS])
+        )
+        self.file_pad.addstr(
+            prev_usel,
+            3,
+            list_format % (prev_pkg[CAT], prev_pkg[PN], 
date2str(prev_pkg[DATE])),
+            curses.color_pair(normal),
+        )
+        self.file_pad.addstr(
+            self.usel, 1, class_char, curses.A_BOLD + 
curses.color_pair(pkg[CLASS])
+        )
+        self.file_pad.addstr(
+            self.usel,
+            3,
+            list_format % (pkg[CAT], pkg[PN], date2str(pkg[DATE])),
+            curses.color_pair(selected),
+        )
 
         first = self.pposy
         last = (self.height // 2 - 2) + first
@@ -414,12 +433,12 @@ class ElogViewer:
         self.show_log()
 
     @staticmethod
-    def open(file, mode='rt'):
-        if file.endswith('.xz'):
+    def open(file, mode="rt"):
+        if file.endswith(".xz"):
             return lzma.open(file, mode=mode)
-        elif file.endswith('.gz'):
+        elif file.endswith(".gz"):
             return gzip.open(file, mode=mode)
-        elif file.endswith('.bz2'):
+        elif file.endswith(".bz2"):
             return bz2.open(file, mode=mode)
         else:
             return open(file, mode=mode)
@@ -432,7 +451,7 @@ class ElogViewer:
         Redraws file pad, first half of the screen.
         Can be used to scroll or simply update
         """
-        self.file_pad.refresh(self.pposy,0,1,1,self.height//2-1,self.width-2)
+        self.file_pad.refresh(self.pposy, 0, 1, 1, self.height // 2 - 1, 
self.width - 2)
 
     def get_packages_key(self, k):
         return k[self.sort_method[0]]
@@ -444,7 +463,9 @@ class ElogViewer:
         """
         # Get the list of files
         try:
-            file_list = glob(os.path.join(elogdir,"*:*:*.log*")) + 
glob(os.path.join(elogdir,"*","*:*.log*"))
+            file_list = glob(os.path.join(elogdir, "*:*:*.log*")) + glob(
+                os.path.join(elogdir, "*", "*:*.log*")
+            )
         except OSError:
             raise CannotOpenElogdir()
 
@@ -465,13 +486,15 @@ class ElogViewer:
             # then we split the string using as pattern / or : to obtain in any
             # case
             # ( "x11-themes", "haematite-xcursors", "1.0:20091018-195827.log")
-            tmpfilepath = re.sub('\\.log[^/]*$', '.log', filepath)
-            split_up = re.split(":|" + os.path.sep, 
tmpfilepath.replace(elogdir + os.path.sep, ""))
+            tmpfilepath = re.sub("\\.log[^/]*$", ".log", filepath)
+            split_up = re.split(
+                ":|" + os.path.sep, tmpfilepath.replace(elogdir + os.path.sep, 
"")
+            )
             if len(split_up) < 3:
                 continue
             (cat, pn, other) = split_up[-3:]
             date = datetime.strptime(other, "%Y%m%d-%H%M%S.log")
-            self.packages.append( (filepath, cat, pn, date, 
self.get_class(filepath)) )
+            self.packages.append((filepath, cat, pn, date, 
self.get_class(filepath)))
 
         if not self.packages:
             raise NoLogFiles()
@@ -479,24 +502,26 @@ class ElogViewer:
         # Maybe that after removing files self.usel points to a wrong index,
         # so this will prevent a crash
         if self.usel >= len(self.packages):
-            self.usel = len(self.packages)-1
+            self.usel = len(self.packages) - 1
             # We also have to update self.pposy
             if self.pposy > self.usel:
-                self.pposy = max(0, self.usel-10)
+                self.pposy = max(0, self.usel - 10)
 
         # Sort the list
         if self.sort_method[0] in (DATE, CLASS):
-            self.packages.sort(key=self.get_packages_key,reverse=not 
self.sort_method[1])
+            self.packages.sort(
+                key=self.get_packages_key, reverse=not self.sort_method[1]
+            )
         else:
             self.packages.sort(key=self.get_packages_key, 
reverse=self.sort_method[1])
 
         # Curses' newpad fails for nlines >32767 so we truncate the list
         # of log files to not exceed that limit (issue #10)
-        MAX_ENTRIES = 2 ** 15 - 1
+        MAX_ENTRIES = 2**15 - 1
         if len(self.packages) > MAX_ENTRIES:
             self.packages = self.packages[:MAX_ENTRIES]
 
-        self.file_pad = curses.newpad(len(self.packages),self.width)
+        self.file_pad = curses.newpad(len(self.packages), self.width)
         self.file_pad.erase()
 
         for i, pkg in enumerate(self.packages):
@@ -513,14 +538,17 @@ class ElogViewer:
             else:
                 cp = normal
 
-            self.file_pad.addstr(i,1,
-                                 class_char,
-                                 curses.A_BOLD + curses.color_pair(pkg[CLASS]))
-            self.file_pad.addstr(i,3,
-                                 list_format % (pkg[CAT], pkg[PN], 
date2str(pkg[DATE]) ),
-                                 curses.color_pair(cp))
-
-    def get_class(self,filepath):
+            self.file_pad.addstr(
+                i, 1, class_char, curses.A_BOLD + curses.color_pair(pkg[CLASS])
+            )
+            self.file_pad.addstr(
+                i,
+                3,
+                list_format % (pkg[CAT], pkg[PN], date2str(pkg[DATE])),
+                curses.color_pair(cp),
+            )
+
+    def get_class(self, filepath):
         """
         Get the highest elog class in a file
         """
@@ -548,7 +576,7 @@ class ElogViewer:
                 yield "\n"
             else:
                 # Returns a list of new lines minus the line ending \n
-                wrapped_line = textwrap.wrap(line, width=self.width-2)
+                wrapped_line = textwrap.wrap(line, width=self.width - 2)
                 for l in wrapped_line:
                     yield l + "\n"
 
@@ -561,7 +589,7 @@ class ElogViewer:
         self.log_win.erase()
         shown_all = False
 
-        for i in range(0,self.height//2-4):
+        for i in range(0, self.height // 2 - 4):
             try:
                 x = next(self.logf_wrap)
             except StopIteration:
@@ -571,27 +599,31 @@ class ElogViewer:
                 break
 
             try:
-                if x.startswith('INFO:'):
-                    
self.log_win.addstr(x[:self.width-2],curses.color_pair(einfo))
-                elif x.startswith('WARN:'):
-                    
self.log_win.addstr(x[:self.width-2],curses.color_pair(ewarn))
-                elif x.startswith('ERROR:'):
-                    
self.log_win.addstr(x[:self.width-2],curses.color_pair(eerror))
-                elif x.startswith('LOG:'):
-                    
self.log_win.addstr(x[:self.width-2],curses.color_pair(elog))
+                if x.startswith("INFO:"):
+                    self.log_win.addstr(x[: self.width - 2], 
curses.color_pair(einfo))
+                elif x.startswith("WARN:"):
+                    self.log_win.addstr(x[: self.width - 2], 
curses.color_pair(ewarn))
+                elif x.startswith("ERROR:"):
+                    self.log_win.addstr(x[: self.width - 2], 
curses.color_pair(eerror))
+                elif x.startswith("LOG:"):
+                    self.log_win.addstr(x[: self.width - 2], 
curses.color_pair(elog))
                 else:
-                    
self.log_win.addstr(x[:self.width-2],curses.color_pair(normal))
+                    self.log_win.addstr(x[: self.width - 2], 
curses.color_pair(normal))
             except curses.error:
                 pass
 
-        if not shown_all: 
+        if not shown_all:
             s = _("Continue...")
-            self.log_win.addstr(self.height//2-3, self.width-len(s)-4, s,
-                                curses.color_pair(normal))
+            self.log_win.addstr(
+                self.height // 2 - 3,
+                self.width - len(s) - 4,
+                s,
+                curses.color_pair(normal),
+            )
 
         self.log_win.refresh()
 
-    def remove_file(self,n):
+    def remove_file(self, n):
         """
         Delete from the filesystem a slice of elog files
         n can be:
@@ -614,24 +646,25 @@ class ElogViewer:
             end = self.usel + int(n)
 
         for item in self.packages[start:end]:
-            os.remove(os.path.join(elogdir,item[0]))
+            os.remove(os.path.join(elogdir, item[0]))
 
     def show_help(self):
         # Setup help window
         helpwin_height = self.height // 3 * 2
         helpwin_corner = (self.height // 6, self.width // 2 - 40)
-        helpwin = curses.newwin(helpwin_height, 80,
-                                     helpwin_corner[0], helpwin_corner[1])
+        helpwin = curses.newwin(
+            helpwin_height, 80, helpwin_corner[0], helpwin_corner[1]
+        )
         helplines = helptext.splitlines()
 
         # Setup help pad
         row = 0
         maxrow = len(helplines)
-        helppad = curses.newpad(maxrow,80)
+        helppad = curses.newpad(maxrow, 80)
 
         # Insert helptext on the pad
         for i in range(maxrow):
-            helppad.addstr(i,0,helplines[i])
+            helppad.addstr(i, 0, helplines[i])
 
         # Loop to manage user actions
         c = None
@@ -640,31 +673,39 @@ class ElogViewer:
             helpwin.border()
             helpwin.refresh()
 
-            helppad.refresh(row,0,helpwin_corner[0]+1,helpwin_corner[1]+1,
-                             
helpwin_height+helpwin_corner[0]-2,80+helpwin_corner[1]-2)
+            helppad.refresh(
+                row,
+                0,
+                helpwin_corner[0] + 1,
+                helpwin_corner[1] + 1,
+                helpwin_height + helpwin_corner[0] - 2,
+                80 + helpwin_corner[1] - 2,
+            )
 
             c = self.screen.getch()
             if c == curses.KEY_NPAGE:
-                if row+10 <= maxrow:
+                if row + 10 <= maxrow:
                     row += 10
             elif c == curses.KEY_PPAGE:
-                if row-10 >= 0:
+                if row - 10 >= 0:
                     row -= 10
             elif c in (curses.KEY_DOWN, ord("j")):
-                if row+1 < maxrow:
+                if row + 1 < maxrow:
                     row += 1
             elif c in (curses.KEY_UP, ord("k")):
                 if row > 0:
                     row -= 1
 
     def search(self, word, div=0):
-        for x in self.packages[self.usel+div:]:
+        for x in self.packages[self.usel + div :]:
             if re.search(word, "%s/%s" % x[1:3]):
-                self.change_usel(self.packages.index(x),False)
+                self.change_usel(self.packages.index(x), False)
                 break
         else:
-            self.screen.addstr(self.height-2,2,_("Not Found!"),
-                curses.color_pair(eerror))
+            self.screen.addstr(
+                self.height - 2, 2, _("Not Found!"), curses.color_pair(eerror)
+            )
+
 
 if __name__ == "__main__":
     if "--help" in sys.argv:
@@ -672,10 +713,12 @@ if __name__ == "__main__":
         sys.exit()
 
     # Get the path of the elogdir
-    if port_settings['PORT_LOGDIR']:
-        elogdir = os.path.join(port_settings['PORT_LOGDIR'],"elog")
+    if port_settings["PORT_LOGDIR"]:
+        elogdir = os.path.join(port_settings["PORT_LOGDIR"], "elog")
     else:
-        elogdir = 
os.path.join(os.sep,port_settings['EPREFIX'],"var","log","portage","elog")
+        elogdir = os.path.join(
+            os.sep, port_settings["EPREFIX"], "var", "log", "portage", "elog"
+        )
 
     signal.signal(signal.SIGTSTP, handle_sig_tstp)
     signal.signal(signal.SIGCONT, handle_sig_cont)
@@ -691,7 +734,9 @@ if __name__ == "__main__":
         sys.exit(1)
     except CannotOpenElogdir:
         print(_("Cannot open"), elogdir)
-        print(_("Please check if the directory exists and if it's readable by 
your user."))
+        print(
+            _("Please check if the directory exists and if it's readable by 
your user.")
+        )
         sys.exit(1)
     except KeyboardInterrupt:
         pass

diff --git a/setup.py b/setup.py
index 631a6c7..d182056 100644
--- a/setup.py
+++ b/setup.py
@@ -14,13 +14,13 @@ from glob import glob
 
 
 class messages(Command):
+    description = "Extract messages from source files"
 
-    description = 'Extract messages from source files'
-
-    user_options = [('merge', 'm', 'Merge message catalogs after '
-                     'extracting template')]
+    user_options = [
+        ("merge", "m", "Merge message catalogs after " "extracting template")
+    ]
 
-    boolean_options = ['merge']
+    boolean_options = ["merge"]
 
     def initialize_options(self):
         self.merge = False
@@ -31,18 +31,18 @@ class messages(Command):
     def run(self):
         wd = os.getcwd()
         name = self.distribution.get_name()
-        logging.info('Extracting messages from %s' % name)
-        os.chdir('po')
-        os.system('pygettext -k i18n -o %s.pot ../%s' % (name, name))
+        logging.info("Extracting messages from %s" % name)
+        os.chdir("po")
+        os.system("pygettext -k i18n -o %s.pot ../%s" % (name, name))
         os.chdir(wd)
         if self.merge:
-            self.run_command('merge')
+            self.run_command("merge")
 
 
 class merge(Command):
-    description = 'Merge message catalogs with template'
+    description = "Merge message catalogs with template"
 
-    user_options = [('lang=', 'l', 'Only merge specified language')]
+    user_options = [("lang=", "l", "Only merge specified language")]
 
     def initialize_options(self):
         self.lang = None
@@ -52,46 +52,44 @@ class merge(Command):
 
     def run(self):
         wd = os.getcwd()
-        os.chdir('po')
+        os.chdir("po")
         if self.lang is not None:
-            filename = '%s.po' % self.lang
+            filename = "%s.po" % self.lang
             if os.path.exists(filename):
                 self.merge(filename)
             else:
-                logging.error('No catalog found for language %s' % self.lang)
+                logging.error("No catalog found for language %s" % self.lang)
         else:
-            files = glob('*.po')
+            files = glob("*.po")
             for f in files:
                 self.merge(f)
         os.chdir(wd)
 
     def merge(self, f):
         name = self.distribution.get_name()
-        logging.info('Merging catalog %s' % f)
-        os.system('msgmerge %s %s.pot -o %s' % (f, name, f))
+        logging.info("Merging catalog %s" % f)
+        os.system("msgmerge %s %s.pot -o %s" % (f, name, f))
 
 
 class build_messages(Command):
-
-    description = 'Compile message catalogs'
-    user_options = [('build-dir=', 'd',
-                     'directory to build message catalogs in')]
+    description = "Compile message catalogs"
+    user_options = [("build-dir=", "d", "directory to build message catalogs 
in")]
 
     def initialize_options(self):
         self.build_dir = None
 
     def finalize_options(self):
-        self.set_undefined_options('build', ('build_messages', 'build_dir'))
+        self.set_undefined_options("build", ("build_messages", "build_dir"))
 
     def run(self):
         self.mkpath(self.build_dir)
-        po_files = os.path.join('po', '*.po')
+        po_files = os.path.join("po", "*.po")
         po_files = glob(po_files)
         for f in po_files:
             base = os.path.basename(f)
             base = os.path.splitext(base)[0]
-            out_file = os.path.join(self.build_dir, '%s.gmo' % base)
-            logging.info('Building catalog %s > %s' % (f, out_file))
+            out_file = os.path.join(self.build_dir, "%s.gmo" % base)
+            logging.info("Building catalog %s > %s" % (f, out_file))
             cmd = 'msgfmt -o "%s" %s' % (out_file, f)
             os.system(cmd)
 
@@ -108,24 +106,24 @@ class build(_build):
     def finalize_options(self):
         _build.finalize_options(self)
         if self.build_messages is None:
-            self.build_messages = os.path.join(self.build_base, 'po')
+            self.build_messages = os.path.join(self.build_base, "po")
 
     _build.user_options.append(
-        ('build-messages=', None, "build directory for messages"))
-    _build.sub_commands.append(('build_messages', has_messages))
+        ("build-messages=", None, "build directory for messages")
+    )
+    _build.sub_commands.append(("build_messages", has_messages))
 
 
 class install_messages(Command):
-
-    description = 'Installs message catalogs'
+    description = "Installs message catalogs"
 
     user_options = [
-        ('install-dir=', 'd', "directory to install scripts to"),
-        ('build-dir=', 'b', "build directory (where to install from)"),
-        ('skip-build', None, "skip the build steps"),
+        ("install-dir=", "d", "directory to install scripts to"),
+        ("build-dir=", "b", "build directory (where to install from)"),
+        ("skip-build", None, "skip the build steps"),
     ]
 
-    boolean_options = ['skip-build']
+    boolean_options = ["skip-build"]
 
     def initialize_options(self):
         self.install_dir = None
@@ -133,26 +131,25 @@ class install_messages(Command):
         self.skip_build = None
 
     def finalize_options(self):
-        self.set_undefined_options('build', ('build_messages', 'build_dir'))
+        self.set_undefined_options("build", ("build_messages", "build_dir"))
         self.set_undefined_options(
-            'install',
-            ('install_data', 'install_dir'),
-            ('force', 'force'),
-            ('skip_build', 'skip_build'),
+            "install",
+            ("install_data", "install_dir"),
+            ("force", "force"),
+            ("skip_build", "skip_build"),
         )
-        self.install_dir = os.path.join(self.install_dir, 'share', 'locale')
+        self.install_dir = os.path.join(self.install_dir, "share", "locale")
 
     def run(self):
         if not self.skip_build:
-            self.run_command('build_messages')
-        catalogs = glob(os.path.join(self.build_dir, '*.gmo'))
+            self.run_command("build_messages")
+        catalogs = glob(os.path.join(self.build_dir, "*.gmo"))
         for c in catalogs:
             base = os.path.basename(c)
             base = os.path.splitext(base)[0]
-            out_dir = os.path.join(self.install_dir, base, 'LC_MESSAGES')
+            out_dir = os.path.join(self.install_dir, base, "LC_MESSAGES")
             self.mkpath(out_dir)
-            out_file = os.path.join(out_dir,
-                                    '%s.mo' % self.distribution.get_name())
+            out_file = os.path.join(out_dir, "%s.mo" % 
self.distribution.get_name())
             self.copy_file(c, out_file)
 
 
@@ -164,15 +161,14 @@ class install(_install):
     def has_manpages(self):
         return True
 
-    _install.sub_commands.append(('install_messages', has_messages))
-    _install.sub_commands.append(('install_manpages', has_manpages))
+    _install.sub_commands.append(("install_messages", has_messages))
+    _install.sub_commands.append(("install_manpages", has_manpages))
 
 
 ### End of snippet ###
 
 
 class install_manpages(Command):
-
     description = "Install man pages"
 
     user_options = []
@@ -184,9 +180,9 @@ class install_manpages(Command):
 
     def finalize_options(self):
         self.set_undefined_options(
-            'install',
-            ('install_data', 'install_dir'),
-            ('root', 'root'),
+            "install",
+            ("install_data", "install_dir"),
+            ("root", "root"),
         )
 
     def run(self):
@@ -204,14 +200,16 @@ class install_manpages(Command):
 
 man_pages = glob("man/*")
 
-setup(packages=[],
-      scripts=['elogv'],
-      cmdclass={
-          'extract_messages': messages,
-          'merge': merge,
-          'build_messages': build_messages,
-          'build': build,
-          'install_messages': install_messages,
-          'install_manpages': install_manpages,
-          'install': install,
-      })
+setup(
+    packages=[],
+    scripts=["elogv"],
+    cmdclass={
+        "extract_messages": messages,
+        "merge": merge,
+        "build_messages": build_messages,
+        "build": build,
+        "install_messages": install_messages,
+        "install_manpages": install_manpages,
+        "install": install,
+    },
+)

Reply via email to