Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed-os
Diff: neo.py
- Revision:
- 7:caeff556648e
- Parent:
- 6:622a477ef55c
- Child:
- 8:1a673572accd
diff -r 622a477ef55c -r caeff556648e neo.py
--- a/neo.py Tue Mar 29 23:30:37 2016 -0500
+++ b/neo.py Tue Mar 29 23:47:28 2016 -0500
@@ -17,10 +17,13 @@
subparser = subparsers.add_parser(name, **kwargs)
for arg in args:
- subparser.add_argument(arg)
+ if arg.endswith('?'):
+ subparser.add_argument(arg.strip('?'), nargs='?')
+ else:
+ subparser.add_argument(arg)
def thunk(parsed_args):
- ordered_args = [vars(parsed_args)[arg] for arg in args]
+ ordered_args = [vars(parsed_args)[arg.strip('?')] for arg in args]
return command(*ordered_args)
subparser.set_defaults(command=thunk)
@@ -64,7 +67,7 @@
continue
elif os.path.isfile(file) and file.endswith('.lib'):
with open(file) as f:
- yield f.read().strip()
+ yield f.read().strip(), file[:-4]
def savelib(repo):
print repo.name, '->', repo.url
@@ -81,12 +84,12 @@
self.update()
@classmethod
- def fromurl(cls, url):
+ def fromurl(cls, url, name=None):
repo = cls.__new__(cls)
m = re.match('^(.*/([+a-zA-Z0-9_-]+)/?)(?:#(.*))?$', url)
repo.repo = m.group(1)
- repo.name = m.group(2)
+ repo.name = name or m.group(2)
repo.hash = m.group(3)
repo.path = os.path.join(os.getcwd(), repo.name)
@@ -127,14 +130,14 @@
return pquery(['hg', 'id', '-i']).strip()
# Clone command
-@subcommand('import', 'url',
+@subcommand('import', 'url', 'name?',
help='recursively import a repository')
-def import_(url):
- repo = Repo.fromurl(url)
+def import_(url, name=None):
+ repo = Repo.fromurl(url, name)
for type in ['git', 'hg']:
try:
- popen([type, 'clone', repo.repo])
+ popen([type, 'clone', repo.repo, repo.path])
break
except:
pass
@@ -148,22 +151,22 @@
repo.update()
with cd(repo.path):
- for lib in iterlibs():
- import_(lib)
+ for url, lib in iterlibs():
+ import_(url, lib)
# Deploy command
@subcommand('deploy',
help='recursively import libraries in current directory')
def deploy():
- for lib in iterlibs():
- import_(lib)
+ for url, lib in iterlibs():
+ import_(url, lib)
# Install/uninstall command
-@subcommand('add', 'url',
+@subcommand('add', 'url', 'name?'
help='add a library to the current repository')
-def add(url):
+def add(url, name):
cwd = Repo()
- repo = Repo.fromurl(url)
+ repo = Repo.fromurl(url, name)
import_(url)
@@ -190,8 +193,8 @@
def synch():
cwd = Repo()
- for lib in iterlibs():
- repo = Repo.fromurl(lib)
+ for url, lib in iterlibs():
+ repo = Repo.fromurl(url, lib)
repo.update()
if lib == repo.url:
continue