Search is not available for this dataset
text stringlengths 75 104k |
|---|
def get_organisation_information(self, query_params=None):
'''
Get information fot this organisation. Returns a dictionary of values.
'''
return self.fetch_json(
uri_path=self.base_uri,
query_params=query_params or {}
) |
def get_boards(self, **query_params):
'''
Get all the boards for this organisation. Returns a list of Board s.
Returns:
list(Board): The boards attached to this organisation
'''
boards = self.get_boards_json(self.base_uri, query_params=query_params)
boards_l... |
def get_members(self, **query_params):
'''
Get all members attached to this organisation. Returns a list of
Member objects
Returns:
list(Member): The members attached to this organisation
'''
members = self.get_members_json(self.base_uri,
... |
def update_organisation(self, query_params=None):
'''
Update this organisations information. Returns a new organisation
object.
'''
organisation_json = self.fetch_json(
uri_path=self.base_uri,
http_method='PUT',
query_params=query_params or {}
... |
def remove_member(self, member_id):
'''
Remove a member from the organisation.Returns JSON of all members if
successful or raises an Unauthorised exception if not.
'''
return self.fetch_json(
uri_path=self.base_uri + '/members/%s' % member_id,
http_method=... |
def add_member_by_id(self, member_id, membership_type='normal'):
'''
Add a member to the board using the id. Membership type can be
normal or admin. Returns JSON of all members if successful or raises an
Unauthorised exception if not.
'''
return self.fetch_json(
... |
def add_member(self, email, fullname, membership_type='normal'):
'''
Add a member to the board. Membership type can be normal or admin.
Returns JSON of all members if successful or raises an Unauthorised
exception if not.
'''
return self.fetch_json(
uri_path=s... |
def get_list_information(self, query_params=None):
'''
Get information for this list. Returns a dictionary of values.
'''
return self.fetch_json(
uri_path=self.base_uri,
query_params=query_params or {}
) |
def add_card(self, query_params=None):
'''
Create a card for this list. Returns a Card object.
'''
card_json = self.fetch_json(
uri_path=self.base_uri + '/cards',
http_method='POST',
query_params=query_params or {}
)
return self.create... |
def get_label_information(self, query_params=None):
'''
Get all information for this Label. Returns a dictionary of values.
'''
return self.fetch_json(
uri_path=self.base_uri,
query_params=query_params or {}
) |
def get_items(self, query_params=None):
'''
Get all the items for this label. Returns a list of dictionaries.
Each dictionary has the values for an item.
'''
return self.fetch_json(
uri_path=self.base_uri + '/checkItems',
query_params=query_params or {}
... |
def _update_label_name(self, name):
'''
Update the current label's name. Returns a new Label object.
'''
label_json = self.fetch_json(
uri_path=self.base_uri,
http_method='PUT',
query_params={'name': name}
)
return self.create_label(la... |
def _update_label_dict(self, query_params={}):
'''
Update the current label. Returns a new Label object.
'''
label_json = self.fetch_json(
uri_path=self.base_uri,
http_method='PUT',
query_params=query_params
)
return self.create_label(... |
def get_authorisation_url(self, application_name, token_expire='1day'):
'''
Returns a URL that needs to be opened in a browser to retrieve an
access token.
'''
query_params = {
'name': application_name,
'expiration': token_expire,
'response_typ... |
def get_card_information(self, query_params=None):
'''
Get information for this card. Returns a dictionary of values.
'''
return self.fetch_json(
uri_path=self.base_uri,
query_params=query_params or {}
) |
def get_board(self, **query_params):
'''
Get board information for this card. Returns a Board object.
Returns:
Board: The board this card is attached to
'''
board_json = self.get_board_json(self.base_uri,
query_params=query_pa... |
def get_list(self, **query_params):
'''
Get list information for this card. Returns a List object.
Returns:
List: The list this card is attached to
'''
list_json = self.get_list_json(self.base_uri,
query_params=query_params)
... |
def get_checklists(self, **query_params):
'''
Get the checklists for this card. Returns a list of Checklist objects.
Returns:
list(Checklist): The checklists attached to this card
'''
checklists = self.get_checklist_json(self.base_uri,
... |
def add_comment(self, comment_text):
'''
Adds a comment to this card by the current user.
'''
return self.fetch_json(
uri_path=self.base_uri + '/actions/comments',
http_method='POST',
query_params={'text': comment_text}
) |
def add_attachment(self, filename, open_file):
'''
Adds an attachment to this card.
'''
fields = {
'api_key': self.client.api_key,
'token': self.client.user_auth_token
}
content_type, body = self.encode_multipart_formdata(
fields=field... |
def add_checklist(self, query_params=None):
'''
Add a checklist to this card. Returns a Checklist object.
'''
checklist_json = self.fetch_json(
uri_path=self.base_uri + '/checklists',
http_method='POST',
query_params=query_params or {}
)
... |
def _add_label_from_dict(self, query_params=None):
'''
Add a label to this card, from a dictionary.
'''
return self.fetch_json(
uri_path=self.base_uri + '/labels',
http_method='POST',
query_params=query_params or {}
) |
def _add_label_from_class(self, label=None):
'''
Add an existing label to this card.
'''
return self.fetch_json(
uri_path=self.base_uri + '/idLabels',
http_method='POST',
query_params={'value': label.id}
) |
def add_member(self, member_id):
'''
Add a member to this card. Returns a list of Member objects.
'''
members = self.fetch_json(
uri_path=self.base_uri + '/idMembers',
http_method='POST',
query_params={'value': member_id}
)
members_lis... |
def encode_multipart_formdata(self, fields, filename, file_values):
'''
Encodes data to updload a file to Trello.
Fields is a dictionary of api_key and token. Filename is the name of
the file and file_values is the open(file).read() string.
'''
boundary = '----------Trell... |
def get_member_information(self, query_params=None):
'''
Get Information for a member. Returns a dictionary of values.
Returns:
dict
'''
return self.fetch_json(
uri_path=self.base_uri,
query_params=query_params or {}
) |
def get_cards(self, **query_params):
'''
Get all cards this member is attached to. Return a list of Card
objects.
Returns:
list(Card): Return all cards this member is attached to
'''
cards = self.get_cards_json(self.base_uri, query_params=query_params)
... |
def get_organisations(self, **query_params):
'''
Get all organisations this member is attached to. Return a list of
Organisation objects.
Returns:
list(Organisation): Return all organisations this member is
attached to
'''
organisations = self.get... |
def create_new_board(self, query_params=None):
'''
Create a new board. name is required in query_params. Returns a Board
object.
Returns:
Board: Returns the created board
'''
board_json = self.fetch_json(
uri_path='/boards',
http_metho... |
def singledispatchmethod(method):
'''
Enable singledispatch for class methods.
See http://stackoverflow.com/a/24602374/274318
'''
dispatcher = singledispatch(method)
def wrapper(*args, **kw):
return dispatcher.dispatch(args[1].__class__)(*args, **kw)
wrapper.register = dispatcher.re... |
def create_checklist_item(self, card_id, checklist_id, checklistitem_json, **kwargs):
'''
Create a ChecklistItem object from JSON object
'''
return self.client.create_checklist_item(card_id, checklist_id, checklistitem_json, **kwargs) |
def get_board_information(self, query_params=None):
'''
Get all information for this board. Returns a dictionary of values.
'''
return self.fetch_json(
uri_path='/boards/' + self.id,
query_params=query_params or {}
) |
def get_lists(self, **query_params):
'''
Get the lists attached to this board. Returns a list of List objects.
Returns:
list(List): The lists attached to this board
'''
lists = self.get_lists_json(self.base_uri, query_params=query_params)
lists_list = []
... |
def get_labels(self, **query_params):
'''
Get the labels attached to this board. Returns a label of Label
objects.
Returns:
list(Label): The labels attached to this board
'''
labels = self.get_labels_json(self.base_uri, query_params=query_params)
lab... |
def get_card(self, card_id, **query_params):
'''
Get a Card for a given card id. Returns a Card object.
Returns:
Card: The card with the given card_id
'''
card_json = self.fetch_json(
uri_path=self.base_uri + '/cards/' + card_id
)
return ... |
def get_checklists( self ):
"""
Get the checklists for this board. Returns a list of Checklist objects.
"""
checklists = self.getChecklistsJson( self.base_uri )
checklists_list = []
for checklist_json in checklists:
checklists_list.append( self.createChecklis... |
def get_organisation(self, **query_params):
'''
Get the Organisation for this board. Returns Organisation object.
Returns:
list(Organisation): The organisation attached to this board
'''
organisation_json = self.get_organisations_json(
self.base_uri, quer... |
def update_board(self, query_params=None):
'''
Update this board's information. Returns a new board.
'''
board_json = self.fetch_json(
uri_path=self.base_uri,
http_method='PUT',
query_params=query_params or {}
)
return self.create_boar... |
def add_list(self, query_params=None):
'''
Create a list for a board. Returns a new List object.
'''
list_json = self.fetch_json(
uri_path=self.base_uri + '/lists',
http_method='POST',
query_params=query_params or {}
)
return self.crea... |
def add_label(self, query_params=None):
'''
Create a label for a board. Returns a new Label object.
'''
list_json = self.fetch_json(
uri_path=self.base_uri + '/labels',
http_method='POST',
query_params=query_params or {}
)
return self.... |
def get_checklist_information(self, query_params=None):
'''
Get all information for this Checklist. Returns a dictionary of values.
'''
# We don't use trelloobject.TrelloObject.get_checklist_json, because
# that is meant to return lists of checklists.
return self.fetch_js... |
def get_card(self):
'''
Get card this checklist is on.
'''
card_id = self.get_checklist_information().get('idCard', None)
if card_id:
return self.client.get_card(card_id) |
def get_item_objects(self, query_params=None):
"""
Get the items for this checklist. Returns a list of ChecklistItem objects.
"""
card = self.get_card()
checklistitems_list = []
for checklistitem_json in self.get_items(query_params):
checklistitems_list.append... |
def update_checklist(self, name):
'''
Update the current checklist. Returns a new Checklist object.
'''
checklist_json = self.fetch_json(
uri_path=self.base_uri,
http_method='PUT',
query_params={'name': name}
)
return self.create_check... |
def add_item(self, query_params=None):
'''
Add an item to this checklist. Returns a dictionary of values of new
item.
'''
return self.fetch_json(
uri_path=self.base_uri + '/checkItems',
http_method='POST',
query_params=query_params or {}
... |
def remove_item(self, item_id):
'''
Deletes an item from this checklist.
'''
return self.fetch_json(
uri_path=self.base_uri + '/checkItems/' + item_id,
http_method='DELETE'
) |
def update_name( self, name ):
"""
Rename the current checklist item. Returns a new ChecklistItem object.
"""
checklistitem_json = self.fetch_json(
uri_path = self.base_uri + '/name',
http_method = 'PUT',
query_params = {'value': name}
)
... |
def update_state(self, state):
"""
Set the state of the current checklist item. Returns a new ChecklistItem object.
"""
checklistitem_json = self.fetch_json(
uri_path = self.base_uri + '/state',
http_method = 'PUT',
query_params = {'value': 'complete' ... |
def add_authorisation(self, query_params):
'''
Adds the API key and user auth token to the query parameters
'''
query_params['key'] = self.api_key
if self.user_auth_token:
query_params['token'] = self.user_auth_token
return query_params |
def check_errors(self, uri, response):
'''
Check HTTP reponse for known errors
'''
if response.status == 401:
raise trolly.Unauthorised(uri, response)
if response.status != 200:
raise trolly.ResourceUnavailable(uri, response) |
def build_uri(self, path, query_params):
'''
Build the URI for the API call.
'''
url = 'https://api.trello.com/1' + self.clean_path(path)
url += '?' + urlencode(query_params)
return url |
def fetch_json(self, uri_path, http_method='GET', query_params=None,
body=None, headers=None):
'''
Make a call to Trello API and capture JSON response. Raises an error
when it fails.
Returns:
dict: Dictionary with the JSON data
'''
query_pa... |
def create_organisation(self, organisation_json):
'''
Create an Organisation object from a JSON object
Returns:
Organisation: The organisation from the given `organisation_json`.
'''
return trolly.organisation.Organisation(
trello_client=self,
... |
def create_board(self, board_json):
'''
Create Board object from a JSON object
Returns:
Board: The board from the given `board_json`.
'''
return trolly.board.Board(
trello_client=self,
board_id=board_json['id'],
name=board_json['na... |
def create_label(self, label_json):
'''
Create Label object from JSON object
Returns:
Label: The label from the given `label_json`.
'''
return trolly.label.Label(
trello_client=self,
label_id=label_json['id'],
name=label_json['name... |
def create_list(self, list_json):
'''
Create List object from JSON object
Returns:
List: The list from the given `list_json`.
'''
return trolly.list.List(
trello_client=self,
list_id=list_json['id'],
name=list_json['name'],
... |
def create_card(self, card_json):
'''
Create a Card object from JSON object
Returns:
Card: The card from the given `card_json`.
'''
return trolly.card.Card(
trello_client=self,
card_id=card_json['id'],
name=card_json['name'],
... |
def create_checklist(self, checklist_json):
'''
Create a Checklist object from JSON object
Returns:
Checklist: The checklist from the given `checklist_json`.
'''
return trolly.checklist.Checklist(
trello_client=self,
checklist_id=checklist_jso... |
def create_checklist_item(self, card_id, checklist_id, checklistitem_json):
"""
Create a ChecklistItem object from JSON object
"""
return trolly.checklist.ChecklistItem(
trello_client=self,
card_id=card_id,
checklist_id=checklist_id,
checkl... |
def create_member(self, member_json):
'''
Create a Member object from JSON object
Returns:
Member: The member from the given `member_json`.
'''
return trolly.member.Member(
trello_client=self,
member_id=member_json['id'],
name=memb... |
def get_organisation(self, id, name=None):
'''
Get an organisation
Returns:
Organisation: The organisation with the given `id`
'''
return self.create_organisation(dict(id=id, name=name)) |
def get_board(self, id, name=None):
'''
Get a board
Returns:
Board: The board with the given `id`
'''
return self.create_board(dict(id=id, name=name)) |
def get_list(self, id, name=None):
'''
Get a list
Returns:
List: The list with the given `id`
'''
return self.create_list(dict(id=id, name=name)) |
def get_card(self, id, name=None):
'''
Get a card
Returns:
Card: The card with the given `id`
'''
return self.create_card(dict(id=id, name=name)) |
def get_checklist(self, id, name=None):
'''
Get a checklist
Returns:
Checklist: The checklist with the given `id`
'''
return self.create_checklist(dict(id=id, name=name)) |
def get_member(self, id='me', name=None):
'''
Get a member or your current member if `id` wasn't given.
Returns:
Member: The member with the given `id`, defaults to the
logged in member.
'''
return self.create_member(dict(id=id, fullName=name)) |
def domain_from_url(url):
"""
Get root domain from url.
Will prune away query strings, url paths, protocol prefix and sub-domains
Exceptions will be raised on invalid urls
"""
ext = tldextract.extract(url)
if not ext.suffix:
raise InvalidURLException()
new_url = ext.domain + "." ... |
def to_raw_text_markupless(text, keep_whitespace=False, normalize_ascii=True):
"""
A generator to convert raw text segments, without xml to a
list of words without any markup.
Additionally dates are replaced by `7777` for normalization.
Arguments
---------
text: str, input text to token... |
def to_raw_text(text, keep_whitespace=False, normalize_ascii=True):
"""
A generator to convert raw text segments, with xml, and other
non-textual content to a list of words without any markup.
Additionally dates are replaced by `7777` for normalization.
Arguments
---------
text: str, inp... |
def to_raw_text_pairings(text, keep_whitespace=False, normalize_ascii=True):
"""
A generator to convert raw text segments, with xml, and other
non-textual content to a list of words without any markup.
Additionally dates are replaced by `7777` for normalization,
along with wikipedia anchors kept.
... |
def detect_sentence_boundaries(tokens):
"""
Subdivide an input list of strings (tokens)
into multiple lists according to detected
sentence boundaries.
```
detect_sentence_boundaries(
["Cat ", "sat ", "mat", ". ", "Cat ", "'s ", "named ", "Cool", "."]
)
#=> [
["Cat ", "sa... |
def sent_tokenize(text, keep_whitespace=False, normalize_ascii=True):
"""
Perform sentence + word tokenization on the input text
using regular expressions and english/french specific
rules.
Arguments:
----------
text : str, input string to tokenize
keep_whitespace : bool, whethe... |
def verbatim_tags(parser, token, endtagname):
"""
Javascript templates (jquery, handlebars.js, mustache.js) use constructs like:
::
{{if condition}} print something{{/if}}
This, of course, completely screws up Django templates,
because Django thinks {{ and }} means something.
The fol... |
def set_password(self, service, username, password):
"""Write the password in the file.
"""
assoc = self._generate_assoc(service, username)
# encrypt the password
password_encrypted = self.encrypt(password.encode('utf-8'), assoc)
# encode with base64 and add line break to... |
def protect_shorthand(text, split_locations):
"""
Annotate locations in a string that contain
periods as being true periods or periods
that are a part of shorthand (and thus should
not be treated as punctuation marks).
Arguments:
----------
text : str
split_locations : list<... |
def split_with_locations(text, locations):
"""
Use an integer list to split the string
contained in `text`.
Arguments:
----------
text : str, same length as locations.
locations : list<int>, contains values
'SHOULD_SPLIT', 'UNDECIDED', and
'SHOULD_NOT_SPLIT'.... |
def mark_regex(regex, text, split_locations):
"""
Regex that adds a 'SHOULD_SPLIT' marker at the end
location of each matching group of the given regex.
Arguments
---------
regex : re.Expression
text : str, same length as split_locations
split_locations : list<int>, split de... |
def mark_begin_end_regex(regex, text, split_locations):
"""
Regex that adds a 'SHOULD_SPLIT' marker at the end
location of each matching group of the given regex,
and adds a 'SHOULD_SPLIT' at the beginning of the
matching group. Each character within the matching
group will be marked as 'SHOULD_... |
def tokenize(text, normalize_ascii=True):
"""
Convert a single string into a list of substrings
split along punctuation and word boundaries. Keep
whitespace intact by always attaching it to the
previous token.
Arguments:
----------
text : str
normalize_ascii : bool, perform ... |
def main(argv=None):
"""Main command line interface."""
if argv is None:
argv = sys.argv[1:]
cli = CommandLineTool()
try:
return cli.run(argv)
except KeyboardInterrupt:
print('Canceled')
return 3 |
def _create_cipher(self, password, salt, nonce = None):
"""
Create the cipher object to encrypt or decrypt a payload.
"""
from argon2.low_level import hash_secret_raw, Type
from Crypto.Cipher import AES
aesmode = self._get_mode(self.aesmode)
if aesmode is None: ... |
def _get_mode(mode = None):
"""
Return the AES mode, or a list of valid AES modes, if mode == None
"""
from Crypto.Cipher import AES
AESModeMap = {
'CCM': AES.MODE_CCM,
'EAX': AES.MODE_EAX,
'GCM': AES.MODE_GCM,
'OCB': AES.MODE_OCB,... |
def priority(self):
"""
Applicable for all platforms, where the schemes, that are integrated
with your environment, does not fit.
"""
try:
__import__('argon2.low_level')
except ImportError: # pragma: no cover
raise RuntimeError("argon2_cffi pac... |
def _check_scheme(self, config):
"""
check for a valid scheme
raise AttributeError if missing
raise ValueError if not valid
"""
try:
scheme = config.get(
escape_for_ini('keyring-setting'),
escape_for_ini('scheme'),
... |
def startLogging(console=True, filepath=None):
'''
Starts the global Twisted logger subsystem with maybe
stdout and/or a file specified in the config file
'''
global logLevelFilterPredicate
observers = []
if console:
observers.append( FilteringLogObserver(observer=textFileLogObse... |
def setLogLevel(namespace=None, levelStr='info'):
'''
Set a new log level for a given namespace
LevelStr is: 'critical', 'error', 'warn', 'info', 'debug'
'''
level = LogLevel.levelWithName(levelStr)
logLevelFilterPredicate.setLogLevelForNamespace(namespace=namespace, level=level) |
def connectToBroker(self, protocol):
'''
Connect to MQTT broker
'''
self.protocol = protocol
self.protocol.onPublish = self.onPublish
self.protocol.onDisconnection = self.onDisconnection
self.protocol.setWindowSize(3)
try:
... |
def onPublish(self, topic, payload, qos, dup, retain, msgId):
'''
Callback Receiving messages from publisher
'''
log.debug("msg={payload}", payload=payload) |
def onDisconnection(self, reason):
'''
get notfied of disconnections
and get a deferred for a new protocol object (next retry)
'''
log.debug("<Connection was lost !> <reason={r}>", r=reason)
self.whenConnected().addCallback(self.connectToBroker) |
def connectToBroker(self, protocol):
'''
Connect to MQTT broker
'''
self.protocol = protocol
self.protocol.onPublish = self.onPublish
self.protocol.onDisconnection = self.onDisconnection
self.protocol.setWindowSize(3)
self.task = task... |
def makeId(self):
'''Produce ids for Protocol packets, outliving their sessions'''
self.id = (self.id + 1) % 65536
self.id = self.id or 1 # avoid id 0
return self.id |
def connect(self, request):
'''
Send a CONNECT control packet.
'''
state = self.__class__.__name__
return defer.fail(MQTTStateError("Unexpected connect() operation", state)) |
def handleCONNACK(self, response):
'''
Handles CONNACK packet from the server
'''
state = self.__class__.__name__
log.error("Unexpected {packet:7} packet received in {log_source}", packet="CONNACK") |
def connect(clientId, keepalive=0, willTopic=None,
willMessage=None, willQoS=0, willRetain=False,
username=None, password=None, cleanStart=True, version=mqtt.v311):
'''
Abstract
========
Send a CONNECT control packet.
Description
=======... |
def encodeString(string):
'''
Encode an UTF-8 string into MQTT format.
Returns a bytearray
'''
encoded = bytearray(2)
encoded.extend(bytearray(string, encoding='utf-8'))
l = len(encoded)-2
if(l > 65535):
raise StringValueError(l)
encoded[0] = l >> 8
encoded[1] = l & 0xFF... |
def decodeString(encoded):
'''
Decodes an UTF-8 string from an encoded MQTT bytearray.
Returns the decoded string and renaining bytearray to be parsed
'''
length = encoded[0]*256 + encoded[1]
return (encoded[2:2+length].decode('utf-8'), encoded[2+length:]) |
def encode16Int(value):
'''
Encodes a 16 bit unsigned integer into MQTT format.
Returns a bytearray
'''
value = int(value)
encoded = bytearray(2)
encoded[0] = value >> 8
encoded[1] = value & 0xFF
return encoded |
def encodeLength(value):
'''
Encodes value into a multibyte sequence defined by MQTT protocol.
Used to encode packet length fields.
'''
encoded = bytearray()
while True:
digit = value % 128
value //= 128
if value > 0:
digit |= 128
encoded.append(digit)... |
def decodeLength(encoded):
'''
Decodes a variable length value defined in the MQTT protocol.
This value typically represents remaining field lengths
'''
value = 0
multiplier = 1
for i in encoded:
value += (i & 0x7F) * multiplier
multiplier *= 0x80
if (i & 0x80) !... |
def encode(self):
'''
Encode and store a DISCONNECT control packet.
'''
header = bytearray(2)
header[0] = 0xE0
self.encoded = header
return str(header) if PY2 else bytes(header) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.