sia_tp_sample / ClusterHQ__powerstrip.jsonl
shahp7575's picture
commit files to HF hub
3a7f06a
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/powerstrip.py","language":"python","identifier":"DockerProxyClient.setStreamingMode","parameters":"(self, streamingMode)","argument_list":"","return_statement":"","docstring":"Allow anyone with a reference to us to toggle on\/off streaming mode.\n Useful when we have no post-hooks (and no indication from Docker that\n it's sending packets of JSON e.g. with build) and we want to avoid\n buffering slow responses in memory.","docstring_summary":"Allow anyone with a reference to us to toggle on\/off streaming mode.\n Useful when we have no post-hooks (and no indication from Docker that\n it's sending packets of JSON e.g. with build) and we want to avoid\n buffering slow responses in memory.","docstring_tokens":["Allow","anyone","with","a","reference","to","us","to","toggle","on","\/","off","streaming","mode",".","Useful","when","we","have","no","post","-","hooks","(","and","no","indication","from","Docker","that","it","s","sending","packets","of","JSON","e",".","g",".","with","build",")","and","we","want","to","avoid","buffering","slow","responses","in","memory","."],"function":"def setStreamingMode(self, streamingMode):\n \"\"\"\n Allow anyone with a reference to us to toggle on\/off streaming mode.\n Useful when we have no post-hooks (and no indication from Docker that\n it's sending packets of JSON e.g. with build) and we want to avoid\n buffering slow responses in memory.\n \"\"\"\n self._streaming = streamingMode\n if streamingMode:\n self._fireListener(Failure(NoPostHooks()))","function_tokens":["def","setStreamingMode","(","self",",","streamingMode",")",":","self",".","_streaming","=","streamingMode","if","streamingMode",":","self",".","_fireListener","(","Failure","(","NoPostHooks","(",")",")",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/powerstrip.py#L46-L55"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/powerstrip.py","language":"python","identifier":"DockerProxyClient.registerListener","parameters":"(self, d)","argument_list":"","return_statement":"","docstring":"Register a one shot listener, which can fire either with:\n * Failure(NoPostHooks()) if the proxy is handling comms back to\n the client (streaming\/chunked modes), or\n * A tuple containing the (response, code, content-type).","docstring_summary":"Register a one shot listener, which can fire either with:\n * Failure(NoPostHooks()) if the proxy is handling comms back to\n the client (streaming\/chunked modes), or\n * A tuple containing the (response, code, content-type).","docstring_tokens":["Register","a","one","shot","listener","which","can","fire","either","with",":","*","Failure","(","NoPostHooks","()",")","if","the","proxy","is","handling","comms","back","to","the","client","(","streaming","\/","chunked","modes",")","or","*","A","tuple","containing","the","(","response","code","content","-","type",")","."],"function":"def registerListener(self, d):\n \"\"\"\n Register a one shot listener, which can fire either with:\n * Failure(NoPostHooks()) if the proxy is handling comms back to\n the client (streaming\/chunked modes), or\n * A tuple containing the (response, code, content-type).\n \"\"\"\n self._listener = d","function_tokens":["def","registerListener","(","self",",","d",")",":","self",".","_listener","=","d"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/powerstrip.py#L57-L64"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/powerstrip.py","language":"python","identifier":"DockerProxyClient._handleRawStream","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Switch the current connection to be a \"hijacked\" aka raw stream: one\n where bytes just get naively proxied back and forth.","docstring_summary":"Switch the current connection to be a \"hijacked\" aka raw stream: one\n where bytes just get naively proxied back and forth.","docstring_tokens":["Switch","the","current","connection","to","be","a","hijacked","aka","raw","stream",":","one","where","bytes","just","get","naively","proxied","back","and","forth","."],"function":"def _handleRawStream(self):\n \"\"\"\n Switch the current connection to be a \"hijacked\" aka raw stream: one\n where bytes just get naively proxied back and forth.\n \"\"\"\n def loseWriteConnectionReason(reason):\n # discard the reason, for compatibility with readConnectionLost\n self.transport.loseWriteConnection()\n self.father.transport.readConnectionLost = loseWriteConnectionReason\n directlyProvides(self.father.transport, IHalfCloseableProtocol)\n self.http = False\n self.father.transport.write(\n \"HTTP\/1.1 200 OK\\r\\n\"\n \"Content-Type: application\/vnd.docker.raw-stream\\r\\n\"\n \"\\r\\n\")\n def stdinHandler(data):\n self.transport.write(data)\n self.father.transport.protocol.dataReceived = stdinHandler\n self.setStreamingMode(True)","function_tokens":["def","_handleRawStream","(","self",")",":","def","loseWriteConnectionReason","(","reason",")",":","# discard the reason, for compatibility with readConnectionLost","self",".","transport",".","loseWriteConnection","(",")","self",".","father",".","transport",".","readConnectionLost","=","loseWriteConnectionReason","directlyProvides","(","self",".","father",".","transport",",","IHalfCloseableProtocol",")","self",".","http","=","False","self",".","father",".","transport",".","write","(","\"HTTP\/1.1 200 OK\\r\\n\"","\"Content-Type: application\/vnd.docker.raw-stream\\r\\n\"","\"\\r\\n\"",")","def","stdinHandler","(","data",")",":","self",".","transport",".","write","(","data",")","self",".","father",".","transport",".","protocol",".","dataReceived","=","stdinHandler","self",".","setStreamingMode","(","True",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/powerstrip.py#L66-L84"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/powerstrip.py","language":"python","identifier":"DockerProxyClient.handleResponsePart","parameters":"(self, buffer)","argument_list":"","return_statement":"","docstring":"If we're not in streaming mode, buffer the response part(s).","docstring_summary":"If we're not in streaming mode, buffer the response part(s).","docstring_tokens":["If","we","re","not","in","streaming","mode","buffer","the","response","part","(","s",")","."],"function":"def handleResponsePart(self, buffer):\n \"\"\"\n If we're not in streaming mode, buffer the response part(s).\n \"\"\"\n if self._streaming:\n proxy.ProxyClient.handleResponsePart(self, buffer)\n else:\n self._responsePartBuffer += buffer","function_tokens":["def","handleResponsePart","(","self",",","buffer",")",":","if","self",".","_streaming",":","proxy",".","ProxyClient",".","handleResponsePart","(","self",",","buffer",")","else",":","self",".","_responsePartBuffer","+=","buffer"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/powerstrip.py#L93-L100"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/powerstrip.py","language":"python","identifier":"DockerProxyClient.handleResponseEnd","parameters":"(self)","argument_list":"","return_statement":"","docstring":"If we're completing a chunked response, up-call to handle it like a\n regular reverse proxy.\n\n If we're completing a non-chunked response, fire the post-hooks.\n\n If we're completing a hijacked response, pass through the connection\n close.","docstring_summary":"If we're completing a chunked response, up-call to handle it like a\n regular reverse proxy.","docstring_tokens":["If","we","re","completing","a","chunked","response","up","-","call","to","handle","it","like","a","regular","reverse","proxy","."],"function":"def handleResponseEnd(self):\n \"\"\"\n If we're completing a chunked response, up-call to handle it like a\n regular reverse proxy.\n\n If we're completing a non-chunked response, fire the post-hooks.\n\n If we're completing a hijacked response, pass through the connection\n close.\n \"\"\"\n if self.http:\n if self._streaming:\n return proxy.ProxyClient.handleResponseEnd(self)\n else:\n contentType = self.father.responseHeaders.getRawHeaders(\"content-type\")\n if contentType:\n contentType = contentType[0]\n else:\n contentType = None\n body = self._responsePartBuffer\n self._fireListener(\n {\"PowerstripProtocolVersion\": 1,\n \"ModifiedServerResponse\":\n {\"Body\": body,\n \"Code\": self.father.code,\n \"ContentType\": contentType}})\n else:\n self.father.transport.loseConnection()","function_tokens":["def","handleResponseEnd","(","self",")",":","if","self",".","http",":","if","self",".","_streaming",":","return","proxy",".","ProxyClient",".","handleResponseEnd","(","self",")","else",":","contentType","=","self",".","father",".","responseHeaders",".","getRawHeaders","(","\"content-type\"",")","if","contentType",":","contentType","=","contentType","[","0","]","else",":","contentType","=","None","body","=","self",".","_responsePartBuffer","self",".","_fireListener","(","{","\"PowerstripProtocolVersion\"",":","1",",","\"ModifiedServerResponse\"",":","{","\"Body\"",":","body",",","\"Code\"",":","self",".","father",".","code",",","\"ContentType\"",":","contentType","}","}",")","else",":","self",".","father",".","transport",".","loseConnection","(",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/powerstrip.py#L103-L130"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/powerstrip.py","language":"python","identifier":"DockerProxy.__init__","parameters":"(self, dockerAddr=None, dockerPort=None, dockerSocket=None,\n path='', reactor=reactor, config=None)","argument_list":"","return_statement":"","docstring":"A docker proxy resource which knows how to connect to real Docker\n daemon either via socket (dockerSocket specified) or address + port for\n TCP connection (dockerAddr + dockerPort specified).","docstring_summary":"A docker proxy resource which knows how to connect to real Docker\n daemon either via socket (dockerSocket specified) or address + port for\n TCP connection (dockerAddr + dockerPort specified).","docstring_tokens":["A","docker","proxy","resource","which","knows","how","to","connect","to","real","Docker","daemon","either","via","socket","(","dockerSocket","specified",")","or","address","+","port","for","TCP","connection","(","dockerAddr","+","dockerPort","specified",")","."],"function":"def __init__(self, dockerAddr=None, dockerPort=None, dockerSocket=None,\n path='', reactor=reactor, config=None):\n \"\"\"\n A docker proxy resource which knows how to connect to real Docker\n daemon either via socket (dockerSocket specified) or address + port for\n TCP connection (dockerAddr + dockerPort specified).\n \"\"\"\n if config is None:\n # Try to get the configuration from the default place on the\n # filesystem.\n self.config = PluginConfiguration()\n else:\n self.config = config\n self.config.read_and_parse()\n self.parser = EndpointParser(self.config)\n Resource.__init__(self)\n self.host = dockerAddr\n self.port = dockerPort\n self.socket = dockerSocket\n self.path = path\n self.reactor = reactor\n proxy.ReverseProxyResource.__init__(self, dockerAddr, dockerPort, path, reactor) # NB dockerAddr is not actually used\n self.agent = Agent(reactor) # no connectionpool\n self.client = HTTPClient(self.agent)","function_tokens":["def","__init__","(","self",",","dockerAddr","=","None",",","dockerPort","=","None",",","dockerSocket","=","None",",","path","=","''",",","reactor","=","reactor",",","config","=","None",")",":","if","config","is","None",":","# Try to get the configuration from the default place on the","# filesystem.","self",".","config","=","PluginConfiguration","(",")","else",":","self",".","config","=","config","self",".","config",".","read_and_parse","(",")","self",".","parser","=","EndpointParser","(","self",".","config",")","Resource",".","__init__","(","self",")","self",".","host","=","dockerAddr","self",".","port","=","dockerPort","self",".","socket","=","dockerSocket","self",".","path","=","path","self",".","reactor","=","reactor","proxy",".","ReverseProxyResource",".","__init__","(","self",",","dockerAddr",",","dockerPort",",","path",",","reactor",")","# NB dockerAddr is not actually used","self",".","agent","=","Agent","(","reactor",")","# no connectionpool","self",".","client","=","HTTPClient","(","self",".","agent",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/powerstrip.py#L166-L189"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_parser.py","language":"python","identifier":"EndpointParser.__init__","parameters":"(self, config)","argument_list":"","return_statement":"","docstring":":param config: A ``PluginConfiguration`` object which has already read\n the current configuration.","docstring_summary":":param config: A ``PluginConfiguration`` object which has already read\n the current configuration.","docstring_tokens":[":","param","config",":","A","PluginConfiguration","object","which","has","already","read","the","current","configuration","."],"function":"def __init__(self, config):\n \"\"\"\n :param config: A ``PluginConfiguration`` object which has already read\n the current configuration.\n \"\"\"\n self.config = config","function_tokens":["def","__init__","(","self",",","config",")",":","self",".","config","=","config"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_parser.py#L17-L22"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_parser.py","language":"python","identifier":"EndpointParser.match_endpoint","parameters":"(self, method, request)","argument_list":"","return_statement":"return matched_endpoints","docstring":"Return a ``set`` of endpoint expressions which match the provided\n ``method`` and ``request``. The items in this set can be provided\n to ``PluginConfiguration.endpoint`` to get the adapter\n configuration.\n\n :param method: An HTTP method string, e.g. \"GET\" or \"POST\".\n\n :param request: An HTTP request path string, e.g. \"\/v1\/containers\/create\".\n\n :return: The set of endpoint expressions to be provided to\n ``PluginConfiguration.endpoint``.\n\n :raises: If the request containers a query part, an ``InvalidRequest`` is raised.","docstring_summary":"Return a ``set`` of endpoint expressions which match the provided\n ``method`` and ``request``. The items in this set can be provided\n to ``PluginConfiguration.endpoint`` to get the adapter\n configuration.","docstring_tokens":["Return","a","set","of","endpoint","expressions","which","match","the","provided","method","and","request",".","The","items","in","this","set","can","be","provided","to","PluginConfiguration",".","endpoint","to","get","the","adapter","configuration","."],"function":"def match_endpoint(self, method, request):\n \"\"\"\n Return a ``set`` of endpoint expressions which match the provided\n ``method`` and ``request``. The items in this set can be provided\n to ``PluginConfiguration.endpoint`` to get the adapter\n configuration.\n\n :param method: An HTTP method string, e.g. \"GET\" or \"POST\".\n\n :param request: An HTTP request path string, e.g. \"\/v1\/containers\/create\".\n\n :return: The set of endpoint expressions to be provided to\n ``PluginConfiguration.endpoint``.\n\n :raises: If the request containers a query part, an ``InvalidRequest`` is raised.\n \"\"\"\n if \"?\" in request:\n raise InvalidRequest()\n all_endpoints = self.config.endpoints()\n match_str = \"%s %s\" % (method, request)\n matched_endpoints = set()\n # Note: fnmatch.filter seemed to be broken when trying to do exaclty this.\n for endpoint in all_endpoints:\n if fnmatch.fnmatch(match_str, endpoint):\n matched_endpoints.add(endpoint)\n return matched_endpoints","function_tokens":["def","match_endpoint","(","self",",","method",",","request",")",":","if","\"?\"","in","request",":","raise","InvalidRequest","(",")","all_endpoints","=","self",".","config",".","endpoints","(",")","match_str","=","\"%s %s\"","%","(","method",",","request",")","matched_endpoints","=","set","(",")","# Note: fnmatch.filter seemed to be broken when trying to do exaclty this.","for","endpoint","in","all_endpoints",":","if","fnmatch",".","fnmatch","(","match_str",",","endpoint",")",":","matched_endpoints",".","add","(","endpoint",")","return","matched_endpoints"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_parser.py#L24-L49"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration.__init__","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Initializes ``PluginConfiguration`` attributes.\n\n self._endpoints: A dict of Docker API endpoint expressions mapping to\n dicts ``pre`` and ``post`` adapter lists. Each adapter in the adapters\n references the ``_adapters`` attribute.\n\n self._adapters: A dict mapping adapter names to URIs.","docstring_summary":"Initializes ``PluginConfiguration`` attributes.","docstring_tokens":["Initializes","PluginConfiguration","attributes","."],"function":"def __init__(self):\n \"\"\"\n Initializes ``PluginConfiguration`` attributes.\n\n self._endpoints: A dict of Docker API endpoint expressions mapping to\n dicts ``pre`` and ``post`` adapter lists. Each adapter in the adapters\n references the ``_adapters`` attribute.\n\n self._adapters: A dict mapping adapter names to URIs.\n \"\"\"\n self._endpoints = {}\n self._adapters = {}","function_tokens":["def","__init__","(","self",")",":","self",".","_endpoints","=","{","}","self",".","_adapters","=","{","}"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L34-L45"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration.read_and_parse","parameters":"(self)","argument_list":"","return_statement":"","docstring":"Read and parse the adapter configuration.\n\n :raises: ``NoConfiguration`` if the configuration file was not found.\n\n :raises: ``InvalidConfiguration`` if the file was not valid configuration.","docstring_summary":"Read and parse the adapter configuration.","docstring_tokens":["Read","and","parse","the","adapter","configuration","."],"function":"def read_and_parse(self):\n \"\"\"\n Read and parse the adapter configuration.\n\n :raises: ``NoConfiguration`` if the configuration file was not found.\n\n :raises: ``InvalidConfiguration`` if the file was not valid configuration.\n \"\"\"\n self.__init__() # reset all attributes\n config_struct = self._read_from_yaml_file(None)\n self._parse_adapters(config_struct)","function_tokens":["def","read_and_parse","(","self",")",":","self",".","__init__","(",")","# reset all attributes","config_struct","=","self",".","_read_from_yaml_file","(","None",")","self",".","_parse_adapters","(","config_struct",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L47-L57"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration._read_from_yaml_file","parameters":"(self, path)","argument_list":"","return_statement":"","docstring":"Read the adapter config YAML file and return the YAML datastructure.\n\n :param path: A ``FilePath`` representing the path to the YAML file, or\n self._default_file if None.\n\n :raises: ``NoConfiguration`` if the adapter file was not found.\n\n :raises: ``InvalidConfiguration`` if if the file was not valid YAML.","docstring_summary":"Read the adapter config YAML file and return the YAML datastructure.","docstring_tokens":["Read","the","adapter","config","YAML","file","and","return","the","YAML","datastructure","."],"function":"def _read_from_yaml_file(self, path):\n \"\"\"\n Read the adapter config YAML file and return the YAML datastructure.\n\n :param path: A ``FilePath`` representing the path to the YAML file, or\n self._default_file if None.\n\n :raises: ``NoConfiguration`` if the adapter file was not found.\n\n :raises: ``InvalidConfiguration`` if if the file was not valid YAML.\n \"\"\"\n if path is None:\n path = FilePath(self._default_file)\n try:\n content = path.getContent()\n except IOError:\n raise NoConfiguration(path.path)\n\n try:\n yaml = safe_load(content)\n return yaml\n except YAMLError:\n raise InvalidConfiguration()","function_tokens":["def","_read_from_yaml_file","(","self",",","path",")",":","if","path","is","None",":","path","=","FilePath","(","self",".","_default_file",")","try",":","content","=","path",".","getContent","(",")","except","IOError",":","raise","NoConfiguration","(","path",".","path",")","try",":","yaml","=","safe_load","(","content",")","return","yaml","except","YAMLError",":","raise","InvalidConfiguration","(",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L59-L81"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration._parse_adapters","parameters":"(self, datastructure)","argument_list":"","return_statement":"","docstring":"Take the decoded YAML configuration and store it as usable\n datastructures. See ``self.__init__``.\n\n :raises: ``InvalidConfiguration`` if the configuration is invalid.","docstring_summary":"Take the decoded YAML configuration and store it as usable\n datastructures. See ``self.__init__``.","docstring_tokens":["Take","the","decoded","YAML","configuration","and","store","it","as","usable","datastructures",".","See","self",".","__init__","."],"function":"def _parse_adapters(self, datastructure):\n \"\"\"\n Take the decoded YAML configuration and store it as usable\n datastructures. See ``self.__init__``.\n\n :raises: ``InvalidConfiguration`` if the configuration is invalid.\n \"\"\"\n try:\n self._endpoints = datastructure[\"endpoints\"]\n except KeyError:\n raise InvalidConfiguration(\"Required key 'endpoints' is missing.\")\n except TypeError:\n raise InvalidConfiguration(\"Could not parse adapters file.\")\n try:\n self._adapters = datastructure[\"adapters\"]\n except KeyError:\n raise InvalidConfiguration(\"Required key 'adapters' is missing.\")\n\n # Sanity check that all referenced adapters exist and that optional pre\n # and post keys are added, with no unknown keys\n known_adapters = self.adapters()\n referenced_adapters = set()\n for endpoint, config in self._endpoints.iteritems():\n config_keys = set(config.keys())\n if not config_keys:\n raise InvalidConfiguration(\n \"No configuration found for endpoint '%s'\" % (endpoint,))\n\n unknown_keys = config_keys - set([\"pre\", \"post\"])\n if unknown_keys:\n raise InvalidConfiguration(\n \"Unkonwn keys found in endpoint configuration: %s\" %\n (\", \".join(unknown_keys)))\n\n if \"pre\" not in config:\n config['pre'] = []\n if \"post\" not in config:\n config['post'] = []\n\n referenced_adapters.update(config['pre'])\n referenced_adapters.update(config['post'])\n\n unkown_adapters = referenced_adapters - known_adapters\n if unkown_adapters:\n raise InvalidConfiguration(\n \"Plugins were referenced in endpoint configuration but not \"\n \"defined: %s\" % (\", \".join(unkown_adapters)))","function_tokens":["def","_parse_adapters","(","self",",","datastructure",")",":","try",":","self",".","_endpoints","=","datastructure","[","\"endpoints\"","]","except","KeyError",":","raise","InvalidConfiguration","(","\"Required key 'endpoints' is missing.\"",")","except","TypeError",":","raise","InvalidConfiguration","(","\"Could not parse adapters file.\"",")","try",":","self",".","_adapters","=","datastructure","[","\"adapters\"","]","except","KeyError",":","raise","InvalidConfiguration","(","\"Required key 'adapters' is missing.\"",")","# Sanity check that all referenced adapters exist and that optional pre","# and post keys are added, with no unknown keys","known_adapters","=","self",".","adapters","(",")","referenced_adapters","=","set","(",")","for","endpoint",",","config","in","self",".","_endpoints",".","iteritems","(",")",":","config_keys","=","set","(","config",".","keys","(",")",")","if","not","config_keys",":","raise","InvalidConfiguration","(","\"No configuration found for endpoint '%s'\"","%","(","endpoint",",",")",")","unknown_keys","=","config_keys","-","set","(","[","\"pre\"",",","\"post\"","]",")","if","unknown_keys",":","raise","InvalidConfiguration","(","\"Unkonwn keys found in endpoint configuration: %s\"","%","(","\", \"",".","join","(","unknown_keys",")",")",")","if","\"pre\"","not","in","config",":","config","[","'pre'","]","=","[","]","if","\"post\"","not","in","config",":","config","[","'post'","]","=","[","]","referenced_adapters",".","update","(","config","[","'pre'","]",")","referenced_adapters",".","update","(","config","[","'post'","]",")","unkown_adapters","=","referenced_adapters","-","known_adapters","if","unkown_adapters",":","raise","InvalidConfiguration","(","\"Plugins were referenced in endpoint configuration but not \"","\"defined: %s\"","%","(","\", \"",".","join","(","unkown_adapters",")",")",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L83-L129"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration.endpoints","parameters":"(self)","argument_list":"","return_statement":"return set(self._endpoints.keys())","docstring":"Return a ``set`` of endpoint expressions.","docstring_summary":"Return a ``set`` of endpoint expressions.","docstring_tokens":["Return","a","set","of","endpoint","expressions","."],"function":"def endpoints(self):\n \"\"\"\n Return a ``set`` of endpoint expressions.\n \"\"\"\n return set(self._endpoints.keys())","function_tokens":["def","endpoints","(","self",")",":","return","set","(","self",".","_endpoints",".","keys","(",")",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L131-L135"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration.endpoint","parameters":"(self, endpoint)","argument_list":"","return_statement":"return EndpointConfiguration(**self._endpoints[endpoint])","docstring":"Return the adapter configuration for the endpoint expression returned by\n ``self.endpoints``. This is an ``EndpointConfiguration` object with attrbutes\n ``pre`` and ``post``. These attributes are lists of adapter names.\n\n :raises: `KeyError` if the endpoint expression was not found.","docstring_summary":"Return the adapter configuration for the endpoint expression returned by\n ``self.endpoints``. This is an ``EndpointConfiguration` object with attrbutes\n ``pre`` and ``post``. These attributes are lists of adapter names.","docstring_tokens":["Return","the","adapter","configuration","for","the","endpoint","expression","returned","by","self",".","endpoints",".","This","is","an","EndpointConfiguration","object","with","attrbutes","pre","and","post",".","These","attributes","are","lists","of","adapter","names","."],"function":"def endpoint(self, endpoint):\n \"\"\"\n Return the adapter configuration for the endpoint expression returned by\n ``self.endpoints``. This is an ``EndpointConfiguration` object with attrbutes\n ``pre`` and ``post``. These attributes are lists of adapter names.\n\n :raises: `KeyError` if the endpoint expression was not found.\n \"\"\"\n return EndpointConfiguration(**self._endpoints[endpoint])","function_tokens":["def","endpoint","(","self",",","endpoint",")",":","return","EndpointConfiguration","(","*","*","self",".","_endpoints","[","endpoint","]",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L137-L145"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration.adapters","parameters":"(self)","argument_list":"","return_statement":"return set(self._adapters.keys())","docstring":"Return a ``set`` of known adapters.","docstring_summary":"Return a ``set`` of known adapters.","docstring_tokens":["Return","a","set","of","known","adapters","."],"function":"def adapters(self):\n \"\"\"\n Return a ``set`` of known adapters.\n \"\"\"\n return set(self._adapters.keys())","function_tokens":["def","adapters","(","self",")",":","return","set","(","self",".","_adapters",".","keys","(",")",")"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L147-L151"}
{"nwo":"ClusterHQ\/powerstrip","sha":"b18dc7261b001720149849b8ed8f2a31880d76c1","path":"powerstrip\/_config.py","language":"python","identifier":"PluginConfiguration.adapter_uri","parameters":"(self, adapter)","argument_list":"","return_statement":"return self._adapters[adapter]","docstring":"Return the URI for a adapter.\n\n :param ``adapter``: The the desired adapter.\n\n :raises: `KeyError` if the adapter was not found.","docstring_summary":"Return the URI for a adapter.","docstring_tokens":["Return","the","URI","for","a","adapter","."],"function":"def adapter_uri(self, adapter):\n \"\"\"\n Return the URI for a adapter.\n\n :param ``adapter``: The the desired adapter.\n\n :raises: `KeyError` if the adapter was not found.\n \"\"\"\n return self._adapters[adapter]","function_tokens":["def","adapter_uri","(","self",",","adapter",")",":","return","self",".","_adapters","[","adapter","]"],"url":"https:\/\/github.com\/ClusterHQ\/powerstrip\/blob\/b18dc7261b001720149849b8ed8f2a31880d76c1\/powerstrip\/_config.py#L153-L161"}