Skip to content

Commit

Permalink
parse_spec merges all return values into the session
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeboers committed Jun 22, 2015
1 parent 52fddb0 commit 67837ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
16 changes: 16 additions & 0 deletions TODO.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
Remote
======

- PostgreSQL based PathCache
- projects still need to be identifiable
- option 1. could just tag them on every machine
- option 2. PathCache can identify project roots
PathCache.iter_project_roots
- option 3. override with envvars: SGFS_PROJECT_65_ROOT

- since data is stored in tag files, which can easily not be transfered to
remote, it is interesting to consider moving that data into the cache as
well, just as a backup. If they both contain a last_updated date or event_id
then it is easy enough to reconcile them


Picker
=======

Expand Down
12 changes: 6 additions & 6 deletions sgfs/commands/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@ def parse_spec(sgfs, spec, entity_types=None, project_from_page=False):
if data:
data.update(entity)
data['__path__'] = path
return data
return sgfs.session.merge(data)
else:
raise ValueError('got not entities from path')

# Shotgun detail URL.
m = re.match(r'^https?://\w+\.shotgunstudio\.com/detail/([A-Za-z]+)/(\d+)', spec)
if m:
return {'type': m.group(1).title(), 'id': int(m.group(2))}
return sgfs.session.merge({'type': m.group(1).title(), 'id': int(m.group(2))})

# Shotgun project overview URL.
m = re.match(r'^https?://\w+\.shotgunstudio\.com/page/\d+#([A-Z][A-Za-z]+)_(\d+)_', spec)
if m:
return {'type': m.group(1).title(), 'id': int(m.group(2))}
return sgfs.session.merge({'type': m.group(1).title(), 'id': int(m.group(2))})

# Shotgun project URL.
m = re.match(r'^https?://\w+\.shotgunstudio\.com/page/(\d+)$', spec)
Expand All @@ -74,16 +74,16 @@ def parse_spec(sgfs, spec, entity_types=None, project_from_page=False):
data = {}
_expand_entity(data, page['project'])
_expand_entity(data, page)
return data
return sgfs.session.merge(data)

# Direct entities. E.g. `shot 12345`
m = re.match(r'^([A-Za-z]{3,}):(\d+)$', spec)
if m:
type_, id_ = m.groups()
return {
return sgfs.session.merge({
'type': type_[0].upper() + type_[1:],
'id': int(id_),
}
})

# TODO: do something with templates.

Expand Down

0 comments on commit 67837ab

Please sign in to comment.