@@ -411,8 +411,8 @@ def _clean_object(self, user_obj, target=None):
411411 obj ["node" ] = user_obj
412412 elif type (user_obj ) is list :
413413 elts = []
414- for obj in user_obj :
415- elts .append (self ._clean_object (obj ))
414+ for item in user_obj :
415+ elts .append (self ._clean_object (item ))
416416 return elts
417417 elif isinstance (user_obj , Var ):
418418 return self ._expand_value_variable (user_obj )
@@ -1510,10 +1510,14 @@ def woql_as(self, *args):
15101510 def file (self , fpath , opts = None ):
15111511 """Provides details of a file source in a JSON format that includes a URL property
15121512
1513+ Note: CSV files can no longer be read from the filesystem. Only files submitted
1514+ as part of the request can be processed. Use remote() for URLs or submit files
1515+ via the API.
1516+
15131517 Parameters
15141518 ----------
1515- fpath : dict
1516- file data source in a JSON format
1519+ fpath : dict or str
1520+ file data source in a JSON format or file path
15171521 opts : input options
15181522 optional
15191523
@@ -1523,7 +1527,7 @@ def file(self, fpath, opts=None):
15231527 query object that can be chained and/or execute
15241528 Example
15251529 -------
1526- To load a local csv file :
1530+ To reference a file (must be submitted with request) :
15271531 >>> WOQLQuery().file("/app/local_files/my.csv")
15281532 See Also
15291533 --------
@@ -1537,8 +1541,10 @@ def file(self, fpath, opts=None):
15371541 if self ._cursor .get ("@type" ):
15381542 self ._wrap_cursor_with_and ()
15391543 self ._cursor ["@type" ] = "QueryResource"
1540- fpath ["@type" ] = "Source"
1541- self ._cursor ["source" ] = fpath
1544+ if isinstance (fpath , str ):
1545+ self ._cursor ["source" ] = {"@type" : "Source" , "file" : fpath }
1546+ else :
1547+ self ._cursor ["source" ] = fpath
15421548 self ._cursor ["format" ] = "csv"
15431549 if opts :
15441550 self ._cursor ["options" ] = opts
@@ -1600,21 +1606,45 @@ def remote(self, uri, opts=None):
16001606 if self ._cursor .get ("@type" ):
16011607 self ._wrap_cursor_with_and ()
16021608 self ._cursor ["@type" ] = "QueryResource"
1603- uri ["@type" ] = "Source"
1604- self ._cursor ["source" ] = uri
1609+ if isinstance (uri , dict ):
1610+ uri ["@type" ] = "Source"
1611+ self ._cursor ["source" ] = uri
1612+ else :
1613+ self ._cursor ["source" ] = {"@type" : "Source" , "url" : uri }
16051614 self ._cursor ["format" ] = "csv"
16061615 if opts :
16071616 self ._cursor ["options" ] = opts
16081617 return self
16091618
16101619 def post (self , fpath , opts = None ):
1620+ """Specifies a file to be posted as part of the request for processing.
1621+
1622+ Note: CSV files can no longer be read from the filesystem. Only files submitted
1623+ as part of the request can be processed. This method should be used with files
1624+ that are uploaded via the API.
1625+
1626+ Parameters
1627+ ----------
1628+ fpath : str or dict
1629+ file path/identifier or dict with file details
1630+ opts : dict, optional
1631+ additional options for file processing
1632+
1633+ Returns
1634+ -------
1635+ WOQLQuery object
1636+ query object that can be chained and/or execute
1637+ """
16111638 if fpath and fpath == "args" :
16121639 return ["source" , "format" , "options" ]
16131640 if self ._cursor .get ("@type" ):
16141641 self ._wrap_cursor_with_and ()
16151642 self ._cursor ["@type" ] = "QueryResource"
1616- fpath ["@type" ] = "Source"
1617- self ._cursor ["source" ] = fpath
1643+ if isinstance (fpath , dict ):
1644+ fpath ["@type" ] = "Source"
1645+ self ._cursor ["source" ] = fpath
1646+ else :
1647+ self ._cursor ["source" ] = {"@type" : "Source" , "post" : fpath }
16181648 self ._cursor ["format" ] = "csv"
16191649 if opts :
16201650 self ._cursor ["options" ] = opts
0 commit comments