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

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
paxtonhare committed Sep 4, 2014
2 parents bb41040 + 3679a54 commit 4f32c50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
19 changes: 8 additions & 11 deletions ml/commands/mark_logic_auto_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@ def __init__(self):
def gen_dynamic_snippets(self):
if (self.dynamic_snippets == None):
self.dynamic_snippets = []
snip_dir = sublime.packages_path() + "/MarkLogic/dynamic_snippets/"
for root, dirnames, filenames in os.walk(snip_dir):
for filename in fnmatch.filter(filenames, '*.json'):
fn = os.path.join(root, filename)
with open(fn, 'r') as f:
self.dynamic_snippets.append(self.create_snippet_object(json.load(f)))
snip_dir = "Packages/MarkLogic/dynamic_snippets/"
for filename in ["function.json"]:
f = MlUtils.load_resource(os.path.join(snip_dir, filename))
self.dynamic_snippets.append(self.create_snippet_object(json.loads(f)))

# load the builtin function snippets from disk
def gen_function_snippets(self):
if (self.function_snippets == None):
self.function_snippets = []

functions_file = sublime.packages_path() + "/MarkLogic/marklogic_builtins/ml-functions.json"
with open(functions_file, 'r') as f:
for s in json.load(f):
self.function_snippets.append(self.create_snippet_object(s))
functions_file = "Packages/MarkLogic/marklogic_builtins/ml-functions.json"
f = MlUtils.load_resource(functions_file)
for s in json.loads(f):
self.function_snippets.append(self.create_snippet_object(s))

# creates a snippet object for storing in a cache
def create_snippet_object(self, snip):
Expand Down
10 changes: 9 additions & 1 deletion ml/ml_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,12 @@ def debug():
@staticmethod
def log(log_me):
if (MlUtils.debug()):
print(log_me)
print(log_me)

@staticmethod
def load_resource(name):
if hasattr(sublime, 'load_resource'):
return sublime.load_resource(name)
else:
with open(os.path.join(sublime.packages_path(), name[9:])) as f:
return f.read()

0 comments on commit 4f32c50

Please sign in to comment.