# Own modules
import fb_tools.common
-__version__ = '0.2.1'
+__version__ = '0.2.2'
MAX_PORT_NUMBER = (2 ** 16) - 1
DEFAULT_CONFIG_DIR = 'pixelpark'
return fb_tools.common.pp(value, indent=indent, width=width, depth=depth)
+# =============================================================================
+def print_out(msg, end='\n', file=None, flush=False):
+
+ print(msg, end=end, file=file, flush=flush)
+
+
+# =============================================================================
+def line(width=None, linechar='-', end='\n', file=None, flush=False):
+
+ lchar = str(linechar).strip()
+ if not lchar:
+ lchar = '-'
+
+ if not width:
+ term_size = shutil.get_terminal_size(
+ (DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT))
+ width = term_size.columns
+
+ lin = (lchar * width)[0:width]
+ print(lin, end=end, file=file, flush=flush)
+
+
# =============================================================================
# vim: ts=4 et list
# Standard modules
import logging
-import shutil
import copy
import pipes
import os
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.3.1'
+__version__ = '0.3.2'
# =============================================================================
env_prefix=env_prefix, config_dir=config_dir
)
- # -------------------------------------------------------------------------
- def line(self, width=None, linechar='-', color=None, end='\n', file=None, flush=False):
- """Print out an line on stdout, if not in quiet mode."""
- if self.quiet:
- return
-
- lchar = str(linechar).strip()
- if not lchar:
- lchar = '-'
-
- if not width:
- term_size = shutil.get_terminal_size((DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT))
- width = term_size.columns
-
- lin = (lchar * width)[0:width]
- if color:
- lin = self.colored(lin, color)
- print(lin, end=end, file=file, flush=flush)
-
- # -------------------------------------------------------------------------
- def empty_line(self, file=None, flush=False):
- """Print out an empty line on stdout, if not in quiet mode."""
- if not self.quiet:
- print('', file=file, flush=flush)
-
# -------------------------------------------------------------------------
def post_init(self):
"""
p = Popen(cmd, stdin=PIPE, universal_newlines=True)
p.communicate(mail.as_string())
+ # -------------------------------------------------------------------------
+ def print(self, msg, color=None, end='\n', file=None, flush=False):
+
+ if color:
+ msg = self.colored(msg, color)
+ print_out(msg, end=end, file=file, flush=flush)
+
+ # -------------------------------------------------------------------------
+ def empty_line(self, end='\n', file=None, flush=False):
+
+ print('', end=end, file=file, flush=flush)
+
+ # -------------------------------------------------------------------------
+ def line(self, width=None, linechar='-', color=None, end='\n', file=None, flush=False):
+
+ lchar = str(linechar).strip()
+ if not lchar:
+ lchar = '-'
+
+ if not width:
+ term_size = shutil.get_terminal_size(
+ (DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT))
+ width = term_size.columns
+
+ lin = (lchar * width)[0:width]
+ if color:
+ lin = self.colored(lin, color)
+ print(lin, end=end, file=file, flush=flush)
+
+
# =============================================================================
if __name__ == "__main__":
_ = XLATOR.gettext
ngettext = XLATOR.ngettext
-__version__ = '0.6.1'
+__version__ = '0.6.2'
# =============================================================================
self.module_name = self.args.module_name[0]
+ LOG.debug(_("Creating a {} object ...").format('ForgeModuleInfo'))
+
self.module_info = ForgeModuleInfo(
appname=self.appname, verbose=self.verbose, base_dir=self.base_dir,
full_name=self.module_name, var_dir=var_dir, initialized=True,)
+ LOG.debug(_("Finished creating a {} object.").format('ForgeModuleInfo'))
+
+ self.initialized = True
+
# -------------------------------------------------------------------------
def _run(self):
from ..errors import BaseModuleInfoError
-__version__ = '0.3.0'
+__version__ = '0.4.1'
LOG = logging.getLogger(__name__)
@classmethod
def from_data(cls, data, appname=None, verbose=0, base_dir=None):
- if verbose > 3:
+ if verbose > 2:
LOG.debug(_("Trying to get data for {} from:").format(
cls.__name__) + '\n' + pp(data))
# -------------------------------------------------------------------------
def apply_data(self, data):
+ if self.verbose > 2:
+ LOG.debug(_("Applying data ..."))
+
if 'slug' in data:
self.slug = data['slug']
if 'uri' in data:
from .owner_info import ForgeOwnerInfo
-__version__ = '0.2.0'
+__version__ = '0.2.1'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def apply_data(self, data):
+ if self.verbose > 2:
+ LOG.debug(_("Applying data ..."))
+
super(BaseForgeModuleInfo, self).apply_data(data)
if 'deprecated_at' in data:
import logging
import copy
import datetime
+import textwrap
# Thisrd party modules
from fb_tools.common import to_bool
# Own modules
from .. import pp
+from .. import DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT
+
from ..xlate import XLATOR
from . import parse_forge_date
from .base_module_info import BaseForgeModuleInfo
-__version__ = '0.2.0'
+__version__ = '0.2.1'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def apply_data(self, data):
+ if self.verbose > 2:
+ LOG.debug(_("Applying data ..."))
+
super(CurrentModuleReleaseInfo, self).apply_data(data)
if 'changelog' in data and data['changelog']:
for task in data['tasks']:
self.tasks.append(copy.copy(task))
+ # -------------------------------------------------------------------------
+
# =============================================================================
if __name__ == "__main__":
import collections
import time
import os
-import shutil
+import inspect
from pathlib import Path
from fb_tools.common import to_bool
# Own modules
-from .. import pp, DEFAULT_FORGE_API_URL, DEFAULT_HTTP_TIMEOUT, MAX_HTTP_TIMEOUT
+from .. import pp, print_out, line
+from .. import DEFAULT_FORGE_API_URL, DEFAULT_HTTP_TIMEOUT, MAX_HTTP_TIMEOUT
from .. import DEFAULT_VAR_DIR
-from .. import DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT
from ..errors import BaseHookError, BaseModuleInfoError
from ..base_moduleinfo import BaseModuleInfo
-from . import parse_forge_date, ForgeModuleInfoError
+from . import parse_forge_date, ForgeModuleInfoError, BaseForgeObject
from .mod_release_info import ModuleReleaseInfo
from .mod_release_list import ModuleReleaseList
from .cur_mod_release_info import CurrentModuleReleaseInfo
from .owner_info import ForgeOwnerInfo
-
-__version__ = '0.6.0'
+__version__ = '0.6.1'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def apply_data(self, data, from_cache=True):
+ if self.verbose > 2:
+ LOG.debug(_("Applying data ..."))
+
fd = data
if from_cache:
@classmethod
def from_data(cls, data, appname=None, verbose=0, base_dir=None):
- if verbose > 3:
+ if verbose > 2:
LOG.debug(_(
"Trying to instantiate a {}-object from:").format(
cls.__name__) + '\n' + pp(data))
LOG.error(msg)
return None
- module_info = cls(appname=appname, verbose=verbose, base_dir=base_dir, full_name=full_name)
+ module_info = ForgeModuleInfo(appname=appname, verbose=verbose, base_dir=base_dir, full_name=full_name)
module_info.apply_data(data)
return module_info
cls, full_name, forge_uri=DEFAULT_FORGE_API_URL, http_timeout=DEFAULT_HTTP_TIMEOUT,
appname=None, verbose=0, base_dir=None):
- module_info = cls(
+ module_info = ForgeModuleInfo(
appname=appname, verbose=verbose, base_dir=base_dir, full_name=full_name,
)
# -------------------------------------------------------------------------
- def show(self, file=None, flush=False):
-
- def my_print(message):
- print(message, file=file, flush=flush)
-
- def my_line(width=None, linechar='-', end='\n'):
- lchar = str(linechar).strip()
- if not lchar:
- lchar = '-'
-
- if not width:
- term_size = shutil.get_terminal_size(
- (DEFAULT_TERMINAL_WIDTH, DEFAULT_TERMINAL_HEIGHT))
- width = term_size.columns
+ def show(self, detail=False, file=None, flush=False):
- lin = (lchar * width)[0:width]
- print(lin, end=end, file=file, flush=flush)
+ if self.verbose > 2:
+ msg = "Base classes of {}:".format(BaseForgeObject)
+ msg += '\n' + pp(inspect.getmro(BaseForgeObject))
+ LOG.debug(msg)
+ msg = "Base classes of {}:".format(BaseModuleInfo)
+ msg += '\n' + pp(inspect.getmro(BaseModuleInfo))
+ LOG.debug(msg)
+ msg = "Base classes of {}:".format(self.__class__.__name__)
+ msg += '\n' + pp(inspect.getmro(self.__class__))
+ LOG.debug(msg)
if not self.exists_on_forge:
msg = _("Module {!r} not found on Puppet forge.").format(self.full_name)
- my_print(msg)
+ print_out(msg, file=file, flush=flush)
return
msg = _("Information about {!r} from Puppet forge:").format(self.full_name)
- my_print(msg)
- my_line(width=len(msg))
- my_print('')
+ print_out(msg, file=file, flush=flush)
+ line(width=len(msg), file=file, flush=flush)
+ print_out('', file=file, flush=flush)
labels = {}
max_len_label = 1
if val is None:
val = '~'
msg = "{lbl:<{max}} {val}".format(lbl=lbl, max=max_len_label, val=val)
- my_print(msg)
- my_print('')
+ print_out(msg, file=file, flush=flush)
+ print_out('', file=file, flush=flush)
+
# =============================================================================
if __name__ == "__main__":
from . import parse_forge_date
from . import BaseForgeObject
-__version__ = '0.2.0'
+__version__ = '0.2.1'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def apply_data(self, data):
+ if self.verbose > 2:
+ LOG.debug(_("Applying data ..."))
+
super(ModuleReleaseInfo, self).apply_data(data)
if 'created_at' in data and data['created_at']:
from . import BaseForgeObject
-__version__ = '0.3.0'
+__version__ = '0.3.1'
LOG = logging.getLogger(__name__)
# -------------------------------------------------------------------------
def apply_data(self, data):
+ if self.verbose > 2:
+ LOG.debug(_("Applying data ..."))
+
super(ForgeOwnerInfo, self).apply_data(data)
if 'gravatar_id' in data: