text stringlengths 0 828 |
|---|
Raises |
------ |
DecodeError |
When there are extra bytes at the end of the packet. |
Returns |
------- |
int |
Number of bytes consumed from ``f``. |
MqttDisconnect |
Object extracted from ``f``. |
"""""" |
assert header.packet_type == MqttControlPacketType.disconnect |
if header.remaining_len != 0: |
raise DecodeError('Extra bytes at end of packet.') |
return 0, MqttDisconnect()" |
1179,"def getter(name, key=None): |
"""""" |
Creates a read-only property for the attribute name *name*. If a *key* |
function is provided, it can be used to post-process the value of the |
attribute. |
"""""" |
if not key: |
key = lambda x: x |
def wrapper(self): |
return key(getattr(self, name)) |
wrapper.__name__ = wrapper.__qualname__ = name |
return property(wrapper)" |
1180,"def connect(self): |
"""""" |
Sets up your Phabricator session, it's not necessary to call |
this directly |
"""""" |
if self.token: |
self.phab_session = {'token': self.token} |
return |
req = self.req_session.post('%s/api/conduit.connect' % self.host, data={ |
'params': json.dumps(self.connect_params), |
'output': 'json', |
'__conduit__': True, |
}) |
# Parse out the response (error handling ommitted) |
result = req.json()['result'] |
self.phab_session = { |
'sessionKey': result['sessionKey'], |
'connectionID': result['connectionID'], |
}" |
1181,"def request(self, method, params=None): |
"""""" |
Make a request to a method in the phabricator API |
:param method: Name of the API method to call |
:type method: basestring |
:param params: Optional dict of params to pass |
:type params: dict |
"""""" |
if params is None: |
params = {} |
if not self.phab_session: |
self.connect() |
url = '%s/api/%s' % (self.host, method) |
params['__conduit__'] = self.phab_session |
req = self.req_session.post(url, data={ |
'params': json.dumps(params), |
'output': 'json', |
}) |
return json.loads( |
req.content.decode(), |
object_pairs_hook=collections.OrderedDict |
)['result']" |
1182,"def get_musiclibrary(): |
lib_files = music_library.get_file_list(config.library_path) |
global lib |
lib = music_library.parse_library(lib_files) |
"""""":type :musiclibrary.MusicLibrary"""""" |
return lib" |
1183,"def install(force=False): |
""""""Install git hooks."""""" |
ret, git_dir, _ = run(""git rev-parse --show-toplevel"") |
if ret != 0: |
click.echo( |
""ERROR: Please run from within a GIT repository."", |
file=sys.stderr) |
raise click.Abort |
git_dir = git_dir[0] |
hooks_dir = os.path.join(git_dir, HOOK_PATH) |
for hook in HOOKS: |
hook_path = os.path.join(hooks_dir, hook) |
if os.path.exists(hook_path): |
if not force: |
click.echo( |
""Hook already exists. Skipping {0}"".format(hook_path), |
file=sys.stderr) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.