Functions
helpers Namespace Reference

Functions

def BlessedPlotsList ()
 
def CallDocDB (function, parameter, value)
 
def GetDoc (docID)
 
def GetTopicsByDocID (docID)
 
def CombineDocLists (_xml, _docIds)
 
def Download (url, destination)
 

Function Documentation

def helpers.BlessedPlotsList ( )

Definition at line 11 of file helpers.py.

References open().

Referenced by bp.GetDocumentInfoFromDocDB(), and GetTopicsByDocID().

12  return json.loads(open(config.BLESSED_PLOTS).read())
13 
14 
15 #///////////////////////////////////////////////////////////////////////////////
16 # Make HTTP request to DocDB
def BlessedPlotsList()
Definition: helpers.py:11
procfile open("FD_BRL_v0.txt")
def helpers.CallDocDB (   function,
  parameter,
  value 
)

Definition at line 17 of file helpers.py.

Referenced by bp.GetDocumentInfoFromDocDB().

17 def CallDocDB(function, parameter, value):
18  # Construct full url from parameter and value
19  url = config.DOCDB_URL + function + '?' + parameter + '=' + value + '&outformat=xml'
20 
21  # Make HTTP request
22  response = requests.get(url, auth=('nova', config.PWD))
23 
24  return xmltodict.parse(response.content)
25 
26 
27 #///////////////////////////////////////////////////////////////////////////////
28 # Get individual document from DocDB
def CallDocDB(function, parameter, value)
Definition: helpers.py:17
def helpers.CombineDocLists (   _xml,
  _docIds 
)

Definition at line 54 of file helpers.py.

References makeTrainCVSamples.int.

Referenced by bp.GetDocumentInfoFromDocDB().

54 def CombineDocLists(_xml, _docIds):
55  for item in _xml:
56  docId = int(item['@id'])
57  if docId not in _docIds:
58  _docIds.append(docId)
59 
60  return 0
61 
62 
63 #///////////////////////////////////////////////////////////////////////////////
64 # Download a file
def CombineDocLists(_xml, _docIds)
Definition: helpers.py:54
def helpers.Download (   url,
  destination 
)

Definition at line 65 of file helpers.py.

References open().

Referenced by bp.DownloadFiles().

65 def Download(url, destination):
66  r = requests.get(url, auth=('nova', config.PWD))
67  with open(destination, "wb") as dest:
68  dest.write(r.content)
69 
procfile open("FD_BRL_v0.txt")
def Download(url, destination)
Definition: helpers.py:65
def helpers.GetDoc (   docID)

Definition at line 29 of file helpers.py.

References runNovaSAM.str.

Referenced by bp.GetDocumentInfoFromDocDB().

29 def GetDoc(docID):
30  # Construct full url from parameter and value
31  url = config.DOCDB_URL + 'ShowDocument?docid=' + str(docID) + '&outformat=xml'
32 
33  # Make HTTP request
34  response = requests.get(url, auth=('nova', config.PWD))
35  return xmltodict.parse(response.content)
36 
37 
38 #///////////////////////////////////////////////////////////////////////////////
39 # Find all the topics to which a given plot belongs
def GetDoc(docID)
Definition: helpers.py:29
def helpers.GetTopicsByDocID (   docID)

Definition at line 40 of file helpers.py.

References BlessedPlotsList().

Referenced by bp.GetDocumentInfoFromDocDB().

40 def GetTopicsByDocID(docID):
41  topics = []
42  for topic in BlessedPlotsList():
43  if docID in topic['docs']:
44  topics.append(topic['category'])
45 
46  if len(topics) == 0:
47  topics = [unicode('uncategorized')]
48 
49  return topics
50 
51 
52 #///////////////////////////////////////////////////////////////////////////////
53 #
def GetTopicsByDocID(docID)
Definition: helpers.py:40
def BlessedPlotsList()
Definition: helpers.py:11