Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8f5b8e83c0 | |||
| 1da98510d3 |
+1
-1
@@ -1,3 +1,3 @@
|
||||
"""A program to help you work with qmk_firmware."""
|
||||
|
||||
__version__ = '0.0.41'
|
||||
__version__ = '0.0.42'
|
||||
|
||||
+19
-3
@@ -8,6 +8,24 @@ from pathlib import Path
|
||||
from milc import cli
|
||||
|
||||
|
||||
def is_qmk_firmware(qmk_firmware):
|
||||
"""Returns True if the given Path() is a qmk_firmware clone.
|
||||
"""
|
||||
paths = [
|
||||
qmk_firmware,
|
||||
qmk_firmware / 'quantum',
|
||||
qmk_firmware / 'requirements.txt',
|
||||
qmk_firmware / 'requirements-dev.txt',
|
||||
qmk_firmware / 'lib/python/qmk/cli/doctor.py'
|
||||
]
|
||||
|
||||
for path in paths:
|
||||
if not path.exists():
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def broken_module_imports():
|
||||
"""Make sure we can import all the python modules.
|
||||
"""
|
||||
@@ -88,9 +106,7 @@ def in_qmk_firmware():
|
||||
"""
|
||||
cur_dir = Path.cwd()
|
||||
while len(cur_dir.parents) > 0:
|
||||
found_lib = cur_dir / 'lib/python/qmk/cli/__init__.py'
|
||||
found_quantum = cur_dir / 'quantum'
|
||||
if found_lib.is_file() and found_quantum.is_dir():
|
||||
if is_qmk_firmware(cur_dir):
|
||||
return cur_dir
|
||||
|
||||
# Move up a directory before the next iteration
|
||||
|
||||
@@ -14,7 +14,7 @@ import milc
|
||||
import milc.subcommand.config # noqa
|
||||
from milc.questions import yesno
|
||||
|
||||
from .helpers import broken_module_imports, find_qmk_firmware
|
||||
from .helpers import broken_module_imports, find_qmk_firmware, is_qmk_firmware
|
||||
|
||||
milc.EMOJI_LOGLEVELS['INFO'] = '{fg_blue}Ψ{style_reset_all}'
|
||||
|
||||
@@ -65,7 +65,7 @@ def main():
|
||||
import qmk_cli.subcommands
|
||||
|
||||
# Check out and initialize the qmk_firmware environment
|
||||
if qmk_firmware.exists():
|
||||
if is_qmk_firmware(qmk_firmware):
|
||||
# All subcommands are run relative to the qmk_firmware root to make it easier to use the right copy of qmk_firmware.
|
||||
os.chdir(str(qmk_firmware))
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from pathlib import Path
|
||||
from milc import cli
|
||||
from milc.questions import yesno
|
||||
from qmk_cli.git import git_clone
|
||||
from qmk_cli.helpers import is_qmk_firmware
|
||||
|
||||
default_base = 'https://github.com'
|
||||
default_repo = 'qmk_firmware'
|
||||
@@ -42,24 +43,6 @@ def git_upstream(destination):
|
||||
return False
|
||||
|
||||
|
||||
def is_qmk_firmware(qmk_firmware):
|
||||
"""Returns True if the given Path() is a qmk_firmware clone.
|
||||
"""
|
||||
paths = [
|
||||
qmk_firmware,
|
||||
qmk_firmware / 'Makefile',
|
||||
qmk_firmware / 'requirements.txt',
|
||||
qmk_firmware / 'requirements-dev.txt',
|
||||
qmk_firmware / 'lib/python/qmk/cli/doctor.py'
|
||||
]
|
||||
|
||||
for path in paths:
|
||||
if not path.exists():
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
@cli.argument('-n', '--no', arg_only=True, action='store_true', help='Answer no to all questions')
|
||||
@cli.argument('-y', '--yes', arg_only=True, action='store_true', help='Answer yes to all questions')
|
||||
@cli.argument('--baseurl', default=default_base, help='The URL all git operations start from. Default: %s' % default_base)
|
||||
|
||||
Reference in New Issue
Block a user