constructor @args: argument dictionary (if None use sys)
(self, args=None)
| 129 | """dotdrop options manager""" |
| 130 | |
| 131 | def __init__(self, args=None): |
| 132 | """constructor |
| 133 | @args: argument dictionary (if None use sys) |
| 134 | """ |
| 135 | # attributes gotten from self.conf.get_settings() |
| 136 | self.banner = None |
| 137 | self.showdiff = None |
| 138 | self.default_actions = [] |
| 139 | self.instignore = None |
| 140 | self.force_chmod = None |
| 141 | self.cmpignore = None |
| 142 | self.impignore = None |
| 143 | self.upignore = None |
| 144 | self.link_on_import = None |
| 145 | self.chmod_on_import = None |
| 146 | self.check_version = None |
| 147 | self.clear_workdir = None |
| 148 | self.key_prefix = None |
| 149 | self.key_separator = None |
| 150 | |
| 151 | # args parsing |
| 152 | self.args = {} |
| 153 | if args: |
| 154 | self.args = args.copy() |
| 155 | else: |
| 156 | self.args = docopt(USAGE, version=VERSION) |
| 157 | |
| 158 | if self.args['gencfg']: |
| 159 | # print config and exit |
| 160 | print(DEFAULT_CONFIG) |
| 161 | sys.exit(0) |
| 162 | |
| 163 | self.debug = self.args['--verbose'] or ENV_DEBUG in os.environ |
| 164 | self.log = Logger(debug=self.debug) |
| 165 | self.dry = self.args['--dry'] |
| 166 | if ENV_NODEBUG in os.environ: |
| 167 | # force disabling debugs |
| 168 | self.debug = False |
| 169 | # selected profile |
| 170 | self.profile = self.args['--profile'] |
| 171 | self.confpath = self._get_config_path() |
| 172 | if not self.confpath: |
| 173 | raise YamlException('no config file found') |
| 174 | self.confpath = os.path.abspath(self.confpath) |
| 175 | self.log.dbg(f'config abs path: {self.confpath}') |
| 176 | if not self.confpath: |
| 177 | raise YamlException('no config file found') |
| 178 | if not os.path.exists(self.confpath): |
| 179 | err = f'config does not exist \"{self.confpath}\"' |
| 180 | raise YamlException(err) |
| 181 | self.log.dbg('#################################################') |
| 182 | self.log.dbg('#################### DOTDROP ####################') |
| 183 | self.log.dbg('#################################################') |
| 184 | self.log.dbg(f'version: {VERSION}') |
| 185 | self.argv = ' '.join(sys.argv) |
| 186 | self.log.dbg(f'command: {self.argv}') |
| 187 | self.log.dbg(f'config file: {self.confpath}') |
| 188 |
nothing calls this directly
no test coverage detected