Skip to content
This repository has been archived by the owner on Jan 12, 2021. It is now read-only.

Commit

Permalink
Merge pull request #408 from dephell/jail-no-config
Browse files Browse the repository at this point in the history
Ignore implicit config in `dephell jail`
  • Loading branch information
orsinium committed Mar 18, 2020
2 parents 3670328 + 3568005 commit dbc9aaa
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dephell/actions/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _beautify(data, *, colors: bool, table: bool) -> str:
# one dict
if isinstance(data, dict):
return tabulate.tabulate(
_flatdict(data).items(),
sorted(_flatdict(data).items()),
headers=('key', 'value'),
tablefmt='fancy_grid',
)
Expand Down
6 changes: 6 additions & 0 deletions dephell/commands/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
class BaseCommand(CommandHandler):
logger = getLogger('dephell.commands')
prog = 'dephell'
find_config = True

@cached_property
def config(self) -> Config:
Expand Down Expand Up @@ -79,6 +80,11 @@ def _attach_config_file(cls, path, env) -> bool:
config.attach_file(path=path, env=env)
return True

# do not implicitly attach file for some commands like `jail`
if not cls.find_config:
cls.logger.debug('cannot find config file')
return False

# if path isn't specified, carefully try default names
for path in CONFIG_NAMES:
if not os.path.exists(path):
Expand Down
3 changes: 3 additions & 0 deletions dephell/commands/generate_authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
class GenerateAuthorsCommand(BaseCommand):
"""Create AUTHORS file for project by git log.
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/generate_contributing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
class GenerateContributingCommand(BaseCommand):
"""Create CONTRIBUTING.md for DepHell-based project.
"""
# because we don't actually use anything from the config
find_config = False
file_name = 'CONTRIBUTING.md'

@staticmethod
Expand Down
3 changes: 3 additions & 0 deletions dephell/commands/generate_editorconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ class GenerateEditorconfigCommand(BaseCommand):
"""Create EditorConfig for project.
https://editorconfig.org/
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
4 changes: 4 additions & 0 deletions dephell/commands/generate_travis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@

class GenerateTravisCommand(BaseCommand):
"""Create .travis.yml for DepHell-based project.
https://docs.travis-ci.com/user/languages/python/
https://docs.travis-ci.com/user/customizing-the-build
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
3 changes: 3 additions & 0 deletions dephell/commands/inspect_gadget.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class InspectGadgetCommand(BaseCommand):
This command shouldn't be documented.
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/jail_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
class JailInstallCommand(BaseCommand):
"""Download and install package into isolated environment.
"""
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/jail_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
class JailListCommand(BaseCommand):
"""Show all jails and their entrypoints.
"""
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/jail_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class JailRemoveCommand(BaseCommand):
"""Remove package isolated environment.
"""
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/jail_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
class JailShowCommand(BaseCommand):
"""Show info about the package isolated environment.
"""
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/jail_try.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
class JailTryCommand(BaseCommand):
"""Try packages into temporary isolated environment.
"""
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/package_bug.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
class PackageBugCommand(BaseCommand):
"""Report bug in a package.
"""
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
3 changes: 3 additions & 0 deletions dephell/commands/package_changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
class PackageChangelogCommand(BaseCommand):
"""Find project changelog.
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/self_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class SelfAuthCommand(BaseCommand):
"""Insert, update or delete credentials.
"""
# because we don't actually use anything from the config
find_config = False
_global_config_path = get_data_dir() / GLOBAL_CONFIG_NAME

@staticmethod
Expand Down
2 changes: 2 additions & 0 deletions dephell/commands/self_autocomplete.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
class SelfAutocompleteCommand(BaseCommand):
"""Enable DepHell commands autocomplete for current shell.
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
Expand Down
3 changes: 3 additions & 0 deletions dephell/commands/self_uncache.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
class SelfUncacheCommand(BaseCommand):
"""Remove dephell cache.
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand Down
9 changes: 7 additions & 2 deletions dephell/commands/self_upgrade.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
class SelfUpgradeCommand(BaseCommand):
"""Upgrade DepHell to the latest version.
"""
# because we don't actually use anything from the config
find_config = False

@staticmethod
def build_parser(parser) -> ArgumentParser:
builders.build_config(parser)
Expand All @@ -27,13 +30,15 @@ def __call__(self) -> bool:
return self._upgrade_repo(path=path)
return self._upgrade_package()

def _upgrade_repo(self, path: Path) -> bool:
@staticmethod
def _upgrade_repo(path: Path) -> bool:
with chdir(path):
cmd = ['git', 'pull', 'origin', 'master']
result = subprocess.run(cmd)
return (result.returncode == 0)

def _upgrade_package(self) -> bool:
@staticmethod
def _upgrade_package() -> bool:
manager = PackageManager(executable=Path(sys.executable))
args = ['-U']
if manager.is_global:
Expand Down
2 changes: 1 addition & 1 deletion docs/cmd-jail-show.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# dephell jail list
# dephell jail show

Shows information about a jail installed by [dephell jail install](cmd-jail-install).

Expand Down

0 comments on commit dbc9aaa

Please sign in to comment.