text stringlengths 0 828 |
|---|
"""""" |
Used as generic step that provides an additional remark/hint |
and enhance the readability/understanding without performing any check. |
.. code-block:: gherkin |
Given that today is ""April 1st"" |
But note that ""April 1st is Fools day (and beware)"" |
"""""" |
log = getattr(context, ""log"", None) |
if log: |
log.info(u""NOTE: %s;"" % remark)" |
1800,"def section(self, resources): |
"""""" Which section is this in, if any """""" |
section = [p for p in self.parents(resources) if p.rtype == 'section'] |
if section: |
return section[0] |
return None" |
1801,"def in_navitem(self, resources, nav_href): |
"""""" Given href of nav item, determine if resource is in it """""" |
# The navhref might end with '/index' so remove it if so |
if nav_href.endswith('/index'): |
nav_href = nav_href[:-6] |
return self.docname.startswith(nav_href)" |
1802,"def is_published(self): |
"""""" Return true if this resource has published date in the past """""" |
now = datetime.now() |
published = self.props.published |
if published: |
return published < now |
return False" |
1803,"def request(self, method, path, query=None, content=None): |
"""""" |
Sends an HTTP request. |
This constructs a full URL, encodes and decodes HTTP bodies, and |
handles invalid responses in a pythonic way. |
@type method: string |
@param method: HTTP method to use |
@type path: string |
@param path: HTTP URL path |
@type query: list of two-tuples |
@param query: query arguments to pass to urllib.urlencode |
@type content: str or None |
@param content: HTTP body content |
@rtype: object |
@return: JSON-Decoded response |
@raises GanetiApiError: If an invalid response is returned |
"""""" |
kwargs = { |
""headers"": headers, |
""timeout"": self.timeout, |
""verify"": False, |
} |
if self.username and self.password: |
kwargs[""auth""] = self.username, self.password |
if content is not None: |
kwargs[""data""] = self._json_encoder.encode(content) |
if query: |
prepare_query(query) |
kwargs[""params""] = query |
url = self._base_url + path |
# print ""Sending request to %s %s"" % (url, kwargs) |
try: |
r = requests.request(method, url, **kwargs) |
except requests.ConnectionError: |
raise GanetiApiError(""Couldn't connect to %s"" % self._base_url) |
except requests.Timeout: |
raise GanetiApiError(""Timed out connecting to %s"" % |
self._base_url) |
if r.status_code != requests.codes.ok: |
raise NotOkayError(str(r.status_code), code=r.status_code) |
if r.content: |
return json.loads(r.content) |
else: |
return None" |
1804,"def start(self): |
"""""" |
Confirm that we may access the target cluster. |
"""""" |
version = self.request(""get"", ""/version"") |
if version != 2: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.