Last active
August 29, 2015 13:56
-
-
Save mcburton/8929429 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
------------ BEGIN WORKFLOW ------------ | |
{ | |
"actions" : [ | |
{ | |
"class" : "WorkflowActionCustom", | |
"pauseBeforeRunning" : false, | |
"customTitle" : "citekey-insert", | |
"parameters" : { | |
"8735E7DC-D0F4-4DB1-AAB7-4F9A72AC141D" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"F7166519-6C46-45B4-9120-13F9952DBD7D" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"9FF8A121-B969-42A6-9357-2718DFE09D3B" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"AE64866F-7D6D-449B-88E0-9904C66171A0" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"097CBF96-95AD-4B8E-8EDD-42D9054BDA0C" : "", | |
"B783CDB9-964A-45EB-96F0-13C819FFE6F3" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"02FDDCDA-7E1D-4D92-BD89-438354C36B20" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"C86CB9BD-17C3-4E53-83C2-CCCC21514FB6" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"20B42460-F4CF-4D59-B3F4-852794E79179" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"D96009A0-0042-4670-B206-03E02BD3C857" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"6DD936B9-3180-4104-99B0-1760FB92CA29" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"5842466B-788C-40ED-845A-E59B9859BDB0" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"F5F61E21-738B-4249-8272-F7BEF6F6F68C" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"__custom_action_parameters__" : [ | |
{ | |
"type" : "basicText", | |
"title" : "Bibliography filename", | |
"key" : "097CBF96-95AD-4B8E-8EDD-42D9054BDA0C", | |
"placeholder" : "*.bib" | |
}, | |
{ | |
"key" : "145DABB1-FA74-4388-8E64-257CF4DD6F6F", | |
"type" : "switch", | |
"title" : "Concatinate Multiple Bibliography files?" | |
} | |
], | |
"0F82E18C-3996-48E3-81B2-4C301E4AC3E6" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"145DABB1-FA74-4388-8E64-257CF4DD6F6F" : false, | |
"__custom_action_script__" : "#coding: utf-8\nimport workflow\nimport editor\nfrom glob import glob\nimport fileinput\n\n\ndef makeCWD(p):\n\t'''Trim the filename from the full path'''\n\treturn ''.join(p.rpartition('\/')[0:2])\n\n# Get the custom parameters as a dictionary (titles are keys):\nparams = workflow.get_parameters()\n\ndef getBibFile(path):\n\t\n\t#fetch the bibliography filename from the workflow parameters\n\tbib_filename = params['Bibliography filename'] if params['Bibliography filename'] else \"*.bib\"\n\t#curretly not paying attention to this parameter.\n\tconcat_multiple = params['Concatinate Multiple Bibliography files?']\n\n\t# Get the current working directory path\t\n\tcwd_path = makeCWD(path)\n\t\n\twith open(path,'r') as f:\n\t\tfirstline = f.readline()\n\t\tif firstline.startswith(\"---\"):\n\t\t\tfor line in f:\n\t\t\t\tif line.startswith(\"bibliography:\"):\n\t\t\t\t\t#print(\"using yaml\")\n\t\t\t\t\tbib_filename = line.split(\": \")[1].strip()\n\t\t\t\t#\tprint(\"bib file: %s\" % bib_filename)\n\t\t\t\telif line.startswith(\"---\"):\n\t\t\t\t#\tprint(\"end of yaml\")\n\t\t\t\t\tbreak\n\t\t\t\t\t\n\t\tbib_path = ''.join([cwd_path, bib_filename]) \n\t\tif bib_filename == '*.bib':\n\t\t\tbib_path = glob(bib_path)\n\t\t\t\t\n\treturn bib_path\n\n\t\t\t\n\n# Get the current file path\nfile_path = editor.get_path()\nbib_path = getBibFile(file_path)\n\nif not bib_path:\n\tconsole.hud_alert(\"No bibliography file found.\")\n\tworkflow.stop()\n\n# use fileinput to iterate over each line of each file \ncitekeys = \"\".join([line.split(\"{\")[1].replace(\",\",\"\") for line in fileinput.input(bib_path) if line.startswith(\"@\")])\nfileinput.close()\n\nworkflow.set_output(citekeys) #output newline string\n\n\n\n", | |
"98F3CE9E-F5CB-410B-9BF6-62AA623C84C1" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"32872562-6971-4C26-AA0F-A07DA303E5DF" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"61B06FD2-BB08-4A43-A6BC-7EB389BB737C" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"55953D75-E2AA-49FF-8CA4-BDD3E40FB89A" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"E81B672F-2DEE-4F8B-BD9E-16FD937BB90A" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
}, | |
"840394EC-909A-45A7-B727-9399469C0494" : { | |
"tokenRanges" : { | |
}, | |
"type" : "advancedText", | |
"text" : "This action runs a Python script that can be configured with your own parameters. Tap the options (▼) button to edit the script or the parameters that are shown here. This comment is actually a text parameter itself – feel free to remove it." | |
} | |
}, | |
"pauseWithoutShowingParameters" : false | |
}, | |
{ | |
"class" : "WorkflowActionSelectFromList", | |
"pauseBeforeRunning" : false, | |
"customTitle" : "", | |
"parameters" : { | |
"title" : "Select Citekeys", | |
"allowMultipleSelection" : false, | |
"showInPopover" : true, | |
"list" : { | |
"tokenRanges" : { | |
"{0, 1}" : "Input" | |
}, | |
"type" : "advancedText", | |
"text" : "?" | |
} | |
}, | |
"pauseWithoutShowingParameters" : false | |
}, | |
{ | |
"class" : "WorkflowActionReplaceSelectedText", | |
"pauseBeforeRunning" : false, | |
"customTitle" : "", | |
"parameters" : { | |
"replacement" : { | |
"tokenRanges" : { | |
"{1, 1}" : "Input" | |
}, | |
"type" : "advancedText", | |
"text" : "@?" | |
} | |
}, | |
"pauseWithoutShowingParameters" : false | |
} | |
], | |
"name" : "citekey-insert" | |
} | |
------------- END WORKFLOW ------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment