Merge branch 'lint/py3-classes' into 'master'

Consequently use Python 3-style classes

See merge request ungleich-public/cdist!898
This commit is contained in:
poljakowski 2020-06-21 17:54:56 +02:00
commit d478bef8a6
18 changed files with 19 additions and 22 deletions

View file

@ -71,7 +71,7 @@ def _graph_dfs_cycle(graph, node, path):
return False return False
class Config(object): class Config:
"""Cdist main class to hold arbitrary data""" """Cdist main class to hold arbitrary data"""
# list of paths (files and/or directories) that will be removed on finish # list of paths (files and/or directories) that will be removed on finish

View file

@ -47,7 +47,7 @@ class MissingObjectIdError(cdist.Error):
return '%s' % (self.message) return '%s' % (self.message)
class CdistObject(object): class CdistObject:
"""Represents a cdist object. """Represents a cdist object.
All interaction with objects in cdist should be done through this class. All interaction with objects in cdist should be done through this class.

View file

@ -38,7 +38,7 @@ class InvalidTypeError(cdist.Error):
self.type_path, self.type_absolute_path, self.source_path) self.type_path, self.type_absolute_path, self.source_path)
class CdistType(object): class CdistType:
"""Represents a cdist type. """Represents a cdist type.
All interaction with types in cdist should be done through this class. All interaction with types in cdist should be done through this class.

View file

@ -92,7 +92,7 @@ code-remote
''' '''
class Code(object): class Code:
"""Generates and executes cdist code scripts. """Generates and executes cdist code scripts.
""" """

View file

@ -63,7 +63,7 @@ type explorer is:
''' '''
class Explorer(object): class Explorer:
"""Executes cdist explorers. """Executes cdist explorers.
""" """

View file

@ -92,7 +92,7 @@ class NoInitialManifestError(cdist.Error):
return repr(self.message) return repr(self.message)
class Manifest(object): class Manifest:
"""Executes cdist manifests. """Executes cdist manifests.
""" """

View file

@ -56,7 +56,7 @@ class DefaultList(list):
return cls(initial.split('\n')) return cls(initial.split('\n'))
class Emulator(object): class Emulator:
def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ): def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ):
self.argv = argv self.argv = argv
self.stdin = stdin self.stdin = stdin

View file

@ -39,7 +39,7 @@ import cdist.exec.util as util
CONF_SUBDIRS_LINKED = ["explorer", "files", "manifest", "type", ] CONF_SUBDIRS_LINKED = ["explorer", "files", "manifest", "type", ]
class Local(object): class Local:
"""Execute commands locally. """Execute commands locally.
All interaction with the local side should be done through this class. All interaction with the local side should be done through this class.

View file

@ -49,7 +49,7 @@ class DecodeError(cdist.Error):
return "Cannot decode output of " + " ".join(self.command) return "Cannot decode output of " + " ".join(self.command)
class Remote(object): class Remote:
"""Execute commands remotely. """Execute commands remotely.
All interaction with the remote side should be done through this class. All interaction with the remote side should be done through this class.

View file

@ -41,7 +41,7 @@ def hostfile_process_line(line, strip_func=str.strip):
return None return None
class HostSource(object): class HostSource:
""" """
Host source object. Host source object.
Source can be a sequence or filename (stdin if \'-\'). Source can be a sequence or filename (stdin if \'-\').

View file

@ -28,8 +28,7 @@ import glob
import fnmatch import fnmatch
class Info(object): class Info:
def __init__(self, conf_dirs, args): def __init__(self, conf_dirs, args):
self.conf_dirs = conf_dirs self.conf_dirs = conf_dirs
self.all = args.all self.all = args.all

View file

@ -79,7 +79,7 @@ def rstrip_nl(s):
return str.rstrip(s, "\n") return str.rstrip(s, "\n")
class Inventory(object): class Inventory:
"""Inventory main class""" """Inventory main class"""
def __init__(self, db_basedir=dist_inventory_db, configuration=None): def __init__(self, db_basedir=dist_inventory_db, configuration=None):

View file

@ -27,7 +27,7 @@ import tempfile
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class Message(object): class Message:
"""Support messaging between types """Support messaging between types
""" """

View file

@ -78,7 +78,7 @@ def get_available_preoses_string(cls):
return "Available PreOS-es:\n{}".format("\n".join(preoses)) return "Available PreOS-es:\n{}".format("\n".join(preoses))
class PreOS(object): class PreOS:
preoses = None preoses = None
@classmethod @classmethod

View file

@ -30,7 +30,7 @@ import os
import subprocess import subprocess
class Debian(object): class Debian:
_preos_name = 'debian' _preos_name = 'debian'
_cdist_preos = True _cdist_preos = True

View file

@ -32,10 +32,8 @@ import cdist.config
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
class Shell(object): class Shell:
def __init__(self, shell=None): def __init__(self, shell=None):
self.shell = shell self.shell = shell
self.target_host = ( self.target_host = (

View file

@ -44,7 +44,7 @@ expected_object_names = sorted([
'__third/moon']) '__third/moon'])
class CdistObjectErrorContext(object): class CdistObjectErrorContext:
def __init__(self, original_error): def __init__(self, original_error):
self.original_error = original_error self.original_error = original_error

View file

@ -177,7 +177,7 @@ class DirectoryDict(collections.MutableMapping):
raise cdist.Error(str(e)) raise cdist.Error(str(e))
class FileBasedProperty(object): class FileBasedProperty:
attribute_class = None attribute_class = None
def __init__(self, path): def __init__(self, path):
@ -189,7 +189,7 @@ class FileBasedProperty(object):
Usage with a sublcass: Usage with a sublcass:
class Foo(object): class Foo:
# note that the actual DirectoryDict is stored as __parameters # note that the actual DirectoryDict is stored as __parameters
# on the instance # on the instance
parameters = DirectoryDictProperty( parameters = DirectoryDictProperty(