QFS6XFBVEOZU5XHI6DKTKGS7CVQ54FJVVOUH6TU3VNAFWFI22MZAC
var ENV = "eventbrite";
var INPUT = `%clipboard`;
var PATTERN = /\b[0-9]{9}\b/g;
ID = INPUT.match(PATTERN);
if (!ID) {
var app = Application.currentApplication();
var message = "Please copy an order ID and try again.";
app.includeStandardAdditions = true;
app.displayNotification(message, {
withTitle: "Order Lookup",
subtitle: "Not an Order ID",
soundName: "text"
});
} else {
ID = ID[0];
var URL = "https://admin." + ENV + ".com/admin/orderinfo/?order_id=" + ID;
var chrome = Application("Google Chrome");
var tab = chrome.Tab({url: URL});
chrome.windows[0].tabs.push(tab);
chrome.activate();
}
ignoreOutput;
var ENV = "eventbrite";
var INPUT = `%clipboard`;
var PATTERN = /\b[0-9]{11}\b/g;
ID = INPUT.match(PATTERN);
if (!ID) {
var app = Application.currentApplication();
var message = "Please copy an event ID and try again.";
app.includeStandardAdditions = true;
app.displayNotification(message, {
withTitle: "Event Lookup",
subtitle: "Not an Event ID",
soundName: "text"
});
} else {
var URL = "https://www." + ENV + ".com/myevent?eid=" + ID;
var chrome = Application('Google Chrome');
var tab = chrome.Tab({url: URL});
chrome.windows[0].tabs.push(tab);
chrome.activate();
}
ignoreOutput;
var ENV = "eventbrite";
var INPUT = `%clipboard`;
var PATTERN = /\b[0-9]{11}\b/g;
ID = INPUT.match(PATTERN);
if (!ID) {
var app = Application.currentApplication();
var message = "Please copy an event ID and try again.";
app.includeStandardAdditions = true;
app.displayNotification(message, {
withTitle: "Event Lookup",
subtitle: "Not an Event ID",
soundName: "text"
});
} else {
var URL = "https://www." + ENV + ".com/edit?eid=" + ID;
var chrome = Application('Google Chrome');
var tab = chrome.Tab({url: URL});
chrome.windows[0].tabs.push(tab);
chrome.activate();
}
ignoreOutput;
{
"snippets": [
{"$order": "./order_lookup.js"},
{"$manage": "./manage_lookup.js"},
{"$edit": "./edit_lookup.js"}
]
}
var ENV = "eventbrite";
var ID = "%clipboard";
var URL = "https://" + ENV + "" + ID + "";
var chrome = Application('Google Chrome');
var tab = chrome.Tab({url: URL});
chrome.windows[0].tabs.push(tab);
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>expandAfterMode</key>
<dict>
<key>expandAfterMode</key>
<integer>0</integer>
<key>groupName</key>
<string>yoyotest</string>
</dict>
<key>snippetsTE2</key>
<array>
<dict>
<key>abbreviation</key>
<string>##example abbreviation##</string>
<key>abbreviationMode</key>
<integer>1</integer>
<key>creationDate</key>
<date>2017-01-23T00:00:00Z</date>
<key>label</key>
<string>##example label##</string>
<key>modificationDate</key>
<date>2017-01-23T00:00:00Z</date>
<key>plainText</key>
<string>##example content##</string>
<key>snippetType</key>
<integer>4</integer>
<key>uuidString</key>
<string></string>
</dict>
</array>
<key>snippetUUIDs</key>
<array>
<string>##example uuid string###</string>
</array>
<key>suggestAbbreviations</key>
<integer>1</integer>
<key>updateFrequency</key>
<integer>0</integer>
<key>uuidString</key>
<string></string>
<key>writable</key>
<integer>1</integer>
</dict>
</plist>
import copy
# import datetime
import xml.etree.ElementTree as ET
import os
import re
import uuid
def get_snippet_content(filepath):
with open(filepath) as file:
return file.read()
def add_snippet_to_te_xml(dict_of_snippets): # abbreviation, content):
tree = ET.parse("./eventbrite/build/template.xml")
snippet_nodes = tree.getroot()[0][7]
template_node = snippet_nodes[0]
# is the parent node which contains a <dict> node relevant nodes are
# abbreviation string: [1]
# label string: [7]
# content string [11]
# uuid string [15]
uuids = []
for k, v in dict_of_snippets.iteritems():
unique_id = uuid.uuid1().__str__().upper()
uuids.append(unique_id)
new_node = copy.deepcopy(template_node)
new_node[1].text = k
new_node[7].text = k
new_node[11].text = v
new_node[15].text = unique_id
snippet_nodes.append(new_node)
snippet_nodes.remove(template_node)
uuids_array_node = tree.getroot()[0][9]
template_node = uuids_array_node[0]
for u in uuids:
new_node = copy.deepcopy(template_node)
new_node.text = u
uuids_array_node.append(new_node)
uuids_array_node.remove(template_node)
tree.write("~/Desktop/efficiency_js_snippets.xml")
def main():
snippets = ["./eventbrite/" + f for f in os.listdir("./eventbrite")
if "snippet.js" in f]
abbreviation_content_dict = {}
for snippet in snippets:
name = re.search(r"\w+(?=_snippet\.js)", snippet)
if name:
name = "$" + name.group(0)
abbreviation_content_dict[name] = get_snippet_content(snippet)
add_snippet_to_te_xml(abbreviation_content_dict)
if __name__ == "__main__":
main()