]> Savannah Git Hosting - gnulib.git/commitdiff
private import; yet another naming simplification
authorDmitry Selyutin <ghostmansd@gmail.com>
Sat, 9 Sep 2017 18:58:23 +0000 (21:58 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Sat, 9 Sep 2017 18:58:23 +0000 (21:58 +0300)
pygnulib/config.py
pygnulib/filesystem.py
pygnulib/generator.py
pygnulib/module.py

index 229e996cc3c2c30c7e75c7efa617711b762e52e9..13835278f5cb0605dfedadfd83c72eda75bbda29 100644 (file)
@@ -2,16 +2,18 @@
 # encoding: UTF-8
 
 
+
 import argparse
 import codecs
 import os
 import re
 import sys
 
-from .error import AutoconfVersionError
+from .error import AutoconfVersionError as _AutoconfVersionError_
+
 
 
-class Config:
+class Base:
     """gnulib generic configuration"""
     _TABLE_ = {
         "root"              : "",
@@ -47,8 +49,8 @@ class Config:
 
     def __init__(self, **kwargs):
         self.__table = dict()
-        for key in Config._TABLE_:
-            self.__table[key] = Config._TABLE_[key]
+        for key in Base._TABLE_:
+            self.__table[key] = Base._TABLE_[key]
         for key, value in kwargs.items():
             self[key] = value
 
@@ -58,7 +60,7 @@ class Config:
 
 
     def __iter__(self):
-        for key in Config._TABLE_:
+        for key in Base._TABLE_:
             value = self[key]
             yield key, value
 
@@ -344,31 +346,31 @@ class Config:
     def include_guard_prefix(self):
         """include guard prefix"""
         prefix = self["macro_prefix"].upper()
-        default = Config._TABLE_["macro_prefix"]
+        default = Base._TABLE_["macro_prefix"]
         return "GL_%s" % prefix if prefix == default else "GL"
 
 
     def __getitem__(self, key):
-        if key not in Config._TABLE_:
+        if key not in Base._TABLE_:
             key = key.replace("-", "_")
-            if key not in Config._TABLE_:
+            if key not in Base._TABLE_:
                 raise KeyError("unsupported option: %r" % key)
         return self.__table[key]
 
 
     def __setitem__(self, key, value):
-        if key not in Config._TABLE_:
+        if key not in Base._TABLE_:
             key = key.replace("_", "-")
-            if key not in Config._TABLE_:
+            if key not in Base._TABLE_:
                 raise KeyError("unsupported option: %r" % key)
         key = key.replace("-", "_")
-        typeid = type(Config._TABLE_[key])
+        typeid = type(Base._TABLE_[key])
         if key == "lgpl":
             if value not in [None, 2, 3]:
                 raise TypeError("lgpl option must be either None or integral version (2 or 3)")
         elif key == "autoconf":
             if value < 2.59:
-                raise AutoconfVersionError(2.59)
+                raise _AutoconfVersionError_(2.59)
         elif not isinstance(value, typeid):
             raise TypeError("%r option must be of %r type" % (key, typeid))
         self.__table[key] = value
@@ -389,7 +391,7 @@ class Config:
         return self.__table.values()
 
 
-class Cache(Config):
+class Cache(Base):
     """gnulib cached configuration"""
     _AUTOCONF_ = {
         "autoconf" : re.compile(".*AC_PREREQ\\(\\[(.*?)\\]\\)", re.S | re.M),
@@ -496,7 +498,7 @@ class Cache(Config):
 
 
 
-class CommandLine(Config):
+class CommandLine(Base):
     """gnulib-tool command line configuration"""
     _LIST_ = (1 << 0)
     _FIND_ = (1 << 1)
index 266ee25f831cc3e896350ee0c3969ee2570e7816..62e4d322d067b3b8548c623d3650f04ab6334909 100644 (file)
@@ -5,9 +5,9 @@
 
 import os
 
-from .config import Config
-from .module import Module
-from .module import FileModule
+from .config import Base as _BaseConfig_
+from .module import Base as _BaseModule_
+from .module import File as _FileModule_
 
 
 
@@ -27,7 +27,7 @@ class Directory:
     def __init__(self, root, config):
         if not isinstance(root, str):
             raise TypeError("root must be of 'str' type")
-        if not isinstance(config, Config):
+        if not isinstance(config, _BaseConfig_):
             raise TypeError("config must be of 'Config' type")
         if not os.path.exists(root):
             raise FileNotFoundError(root)
@@ -95,7 +95,7 @@ class Git(Directory):
         if name in Git._EXCLUDE_:
             raise ValueError("illegal module name")
         path = os.path.join(self["modules"], name)
-        return FileModule(path, name=name) if full else Module(name)
+        return _FileModule_(path, name=name) if full else _BaseModule_(name)
 
 
     def modules(self, full=True):
index b99cd1fbf7b04f7ca6075373cc125bbd917cdf31..1a52b5848cc3e9cddd31808bad70d489632db68a 100644 (file)
@@ -5,8 +5,8 @@
 
 import os
 
-from .config import Config
-from .module import Module
+from .config import Base as _BaseConfig_
+from .module import Base as _BaseModule_
 
 
 
@@ -92,7 +92,7 @@ class POMakefile(Generator):
         "USE_MSGCTXT = no"
     )
     def __init__(self, config):
-        if not isinstance(config, Config):
+        if not isinstance(config, _BaseConfig_):
             raise TypeError("config must be of pygnulib.Config type")
         super().__init__()
         self.__config = config
@@ -133,7 +133,7 @@ class POMakefile(Generator):
 class POTFILES(Generator):
     """file list to be passed to xgettext"""
     def __init__(self, config, files):
-        if not isinstance(config, Config):
+        if not isinstance(config, _BaseConfig_):
             raise TypeError("config must be of pygnulib.Config type")
         super().__init__()
         self.__config = config
@@ -170,9 +170,9 @@ class AutoconfSnippet(Generator):
         no_libtool: disable libtool (regardless of configuration)
         no_gettext: disable AM_GNU_GETTEXT invocations if True
         """
-        if not isinstance(config, Config):
+        if not isinstance(config, _BaseConfig_):
             raise TypeError("config must be of pygnulib.config.Config type")
-        if not isinstance(module, Module):
+        if not isinstance(module, _BaseModule_):
             raise TypeError("module must be of pygnulib.module.Module type")
         if not isinstance(toplevel, bool):
             raise TypeError("toplevel must be of bool type")
@@ -259,7 +259,7 @@ class InitMacro(Generator):
         config: gnulib configuration
         macro_prefix: macro prefix; if None, consider configuration
         """
-        if not isinstance(config, Config):
+        if not isinstance(config, _BaseConfig_):
             raise TypeError("config must be of pygnulib.config.Config type")
         if macro_prefix is None:
             macro_prefix = config.macro_prefix
index 713b2b0f3f311bac1b071b558e2a407a14f7f132..365914e662515e31a85ae07a1f8b3d07270e95d3 100644 (file)
@@ -11,7 +11,7 @@ import re
 
 
 
-class Module:
+class Base:
     """gnulib generic module"""
     _TABLE_ = {
         "description"            : (0x00, str, "Description"),
@@ -38,7 +38,7 @@ class Module:
             raise TypeError("name must be of 'str' type")
         self.__name = name
         self.__table = {"maintainers": ["all"]}
-        for key in Module._TABLE_:
+        for key in Base._TABLE_:
             self.__table[key] = ""
         for key, value in kwargs.items():
             self.__table[key] = value
@@ -141,7 +141,7 @@ class Module:
     def dependencies(self):
         """dependencies iterator (name, condition)"""
         for entry in self.__table["dependencies"]:
-            yield Module._PATTERN_DEPENDENCIES_.findall(entry)[0]
+            yield Base._PATTERN_DEPENDENCIES_.findall(entry)[0]
 
     @dependencies.setter
     def dependencies(self, iterable):
@@ -202,7 +202,7 @@ class Module:
     def include(self):
         """include files iterator (header, comment)"""
         for entry in self.__table["include"]:
-            match = Module._PATTERN_INCLUDE_.findall(entry)
+            match = Base._PATTERN_INCLUDE_.findall(entry)
             yield match[0] if match else entry
 
     @include.setter
@@ -311,7 +311,7 @@ class Module:
 
     def __str__(self):
         result = ""
-        for key, (_, typeid, field) in sorted(Module._TABLE_.items(), key=lambda k: k[1][0]):
+        for key, (_, typeid, field) in sorted(Base._TABLE_.items(), key=lambda k: k[1][0]):
             field += ":\n"
             if typeid is list:
                 value = "\n".join(self.__table[key])
@@ -344,7 +344,7 @@ class Module:
 
 
 
-class FileModule(Module):
+class File(Base):
     """gnulib module text file"""
     _TABLE_ = {
         "Description"        : (str, "description"),
@@ -362,7 +362,7 @@ class FileModule(Module):
         "License"            : (str, "license"),
         "Maintainer"         : (list, "maintainers"),
     }
-    _FIELDS_ = [field for (_, _, field) in Module._TABLE_.values()]
+    _FIELDS_ = [field for (_, _, field) in Base._TABLE_.values()]
     _PATTERN_ = re.compile("(%s):" % "|".join(_FIELDS_))
 
 
@@ -381,9 +381,9 @@ class FileModule(Module):
                     or (line.startswith("/*") and line.endswith("*/")):
                         continue
                     data += (line + "\n")
-            match = FileModule._PATTERN_.split(data)[1:]
+            match = File._PATTERN_.split(data)[1:]
             for (group, value) in zip(match[::2], match[1::2]):
-                (typeid, key) = FileModule._TABLE_[group]
+                (typeid, key) = File._TABLE_[group]
                 if typeid is list:
                     table[key] = [_ for _ in "".join(value).split("\n") if _.strip()]
                 else: