Search is not available for this dataset
text stringlengths 75 104k |
|---|
def process_tables(key, value, fmt, meta):
"""Processes the attributed tables."""
global has_unnumbered_tables # pylint: disable=global-statement
# Process block-level Table elements
if key == 'Table':
# Inspect the table
if len(value) == 5: # Unattributed, bail out
has_... |
def main():
"""Filters the document AST."""
# pylint: disable=global-statement
global PANDOCVERSION
global AttrTable
# Get the output format and document
fmt = args.fmt
doc = json.loads(STDIN.read())
# Initialize pandocxnos
# pylint: disable=too-many-function-args
PANDOCVERSIO... |
def request(url, xml):
"""Make a http request to clockwork, using the XML provided
Sets sensible headers for the request.
If there is a problem with the http connection a clockwork_exceptions.HttpException is raised
"""
r = _urllib.Request(url, xml)
r.add_header('Content-Type'... |
def get_balance(self):
"""Check the balance fot this account.
Returns a dictionary containing:
account_type: The account type
balance: The balance remaining on the account
currency: The currency used for the account balance. Assume GBP in not set"""
xml_root ... |
def send(self, messages):
"""Send a SMS message, or an array of SMS messages"""
tmpSms = SMS(to='', message='')
if str(type(messages)) == str(type(tmpSms)):
messages = [messages]
xml_root = self.__init_xml('Message')
wrapper_id = 0
for m in messages:
... |
def __init_xml(self, rootElementTag):
"""Init a etree element and pop a key in there"""
xml_root = etree.Element(rootElementTag)
key = etree.SubElement(xml_root, "Key")
key.text = self.apikey
return xml_root |
def __build_sms_data(self, message):
"""Build a dictionary of SMS message elements"""
attributes = {}
attributes_to_translate = {
'to' : 'To',
'message' : 'Content',
'client_id' : 'ClientID',
'concat' : 'Concat',
'from_name': 'From',
... |
def pstats2entries(data):
"""Helper to convert serialized pstats back to a list of raw entries.
Converse operation of cProfile.Profile.snapshot_stats()
"""
# Each entry's key is a tuple of (filename, line number, function name)
entries = {}
allcallers = {}
# first pass over stats to build ... |
def is_installed(prog):
"""Return whether or not a given executable is installed on the machine."""
with open(os.devnull, 'w') as devnull:
try:
if os.name == 'nt':
retcode = subprocess.call(['where', prog], stdout=devnull)
else:
retcode = subproces... |
def main():
"""Execute the converter using parameters provided on the command line"""
parser = argparse.ArgumentParser()
parser.add_argument('-o', '--outfile', metavar='output_file_path',
help="Save calltree stats to <outfile>")
parser.add_argument('-i', '--infile', metavar='inp... |
def convert(profiling_data, outputfile):
"""convert `profiling_data` to calltree format and dump it to `outputfile`
`profiling_data` can either be:
- a pstats.Stats instance
- the filename of a pstats.Stats dump
- the result of a call to cProfile.Profile.getstats()
`outputfile` can... |
def output(self, out_file):
"""Write the converted entries to out_file"""
self.out_file = out_file
out_file.write('event: ns : Nanoseconds\n')
out_file.write('events: ns\n')
self._output_summary()
for entry in sorted(self.entries, key=_entry_sort_key):
self._o... |
def visualize(self):
"""Launch kcachegrind on the converted entries.
One of the executables listed in KCACHEGRIND_EXECUTABLES
must be present in the system path.
"""
available_cmd = None
for cmd in KCACHEGRIND_EXECUTABLES:
if is_installed(cmd):
... |
def get_app(self, reference_app=None):
"""Helper method that implements the logic to look up an application."""
if reference_app is not None:
return reference_app
if self.app is not None:
return self.app
ctx = stack.top
if ctx is not None:
... |
def init_app(self, app, **kwargs):
""" Initializes the Flask-Bouncer extension for the specified application.
:param app: The application.
"""
self.app = app
self._init_extension()
self.app.before_request(self.check_implicit_rules)
if kwargs.get('ensure_author... |
def check_authorization(self, response):
"""checks that an authorization call has been made during the request"""
if not hasattr(request, '_authorized'):
raise Unauthorized
elif not request._authorized:
raise Unauthorized
return response |
def check_implicit_rules(self):
""" if you are using flask classy are using the standard index,new,put,post, etc ... type routes, we will
automatically check the permissions for you
"""
if not self.request_is_managed_by_flask_classy():
return
if self.method_is_ex... |
def rotate_texture(texture, rotation, x_offset=0.5, y_offset=0.5):
"""Rotates the given texture by a given angle.
Args:
texture (texture): the texture to rotate
rotation (float): the angle of rotation in degrees
x_offset (float): the x component of the center of rotation (optional)
... |
def fit_texture(layer):
"""Fits a layer into a texture by scaling each axis to (0, 1).
Does not preserve aspect ratio (TODO: make this an option).
Args:
layer (layer): the layer to scale
Returns:
texture: A texture.
"""
x, y = layer
x = (x - np.nanmin(x)) / (np.nanmax(x) -... |
def check_valid_solution(solution, graph):
"""Check that the solution is valid: every path is visited exactly once."""
expected = Counter(
i for (i, _) in graph.iter_starts_with_index()
if i < graph.get_disjoint(i)
)
actual = Counter(
min(i, graph.get_disjoint(i))
for i i... |
def get_route_from_solution(solution, graph):
"""Converts a solution (a list of node indices) into a list
of paths suitable for rendering."""
# As a guard against comparing invalid "solutions",
# ensure that this solution is valid.
assert check_valid_solution(solution, graph)
return [graph.get... |
def branching_turtle_generator(turtle_program, turn_amount=DEFAULT_TURN,
initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1):
"""Given a turtle program, creates a generator of turtle positions.
The state of the turtle consists of its position and angle.
The turtle starts a... |
def turtle_to_texture(turtle_program, turn_amount=DEFAULT_TURN,
initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1):
"""Makes a texture from a turtle program.
Args:
turtle_program (str): a string representing the turtle program; see the
docstring of `branching_turtle_ge... |
def transform_sequence(sequence, transformations):
"""Applies a given set of substitution rules to the given string or generator.
For more background see: https://en.wikipedia.org/wiki/L-system
Args:
sequence (str): a string or generator onto which transformations are applied
transform... |
def transform_multiple(sequence, transformations, iterations):
"""Chains a transformation a given number of times.
Args:
sequence (str): a string or generator onto which transformations are applied
transformations (dict): a dictionary mapping each char to the string that is
substitu... |
def l_system(axiom, transformations, iterations=1, angle=45, resolution=1):
"""Generates a texture by running transformations on a turtle program.
First, the given transformations are applied to the axiom. This is
repeated `iterations` times. Then, the output is run as a turtle
program to get a texture... |
def get_path(self, i):
"""Returns the path corresponding to the node i."""
index = (i - 1) // 2
reverse = (i - 1) % 2
path = self.paths[index]
if reverse:
return path.reversed()
else:
return path |
def cost(self, i, j):
"""Returns the distance between the end of path i
and the start of path j."""
return dist(self.endpoints[i][1], self.endpoints[j][0]) |
def get_coordinates(self, i, end=False):
"""Returns the starting coordinates of node i as a pair,
or the end coordinates iff end is True."""
if end:
endpoint = self.endpoints[i][1]
else:
endpoint = self.endpoints[i][0]
return (endpoint.real, endpoint.imag) |
def iter_starts_with_index(self):
"""Returns a generator over (index, start coordinate) pairs,
excluding the origin."""
for i in range(1, len(self.endpoints)):
yield i, self.get_coordinates(i) |
def iter_disjunctions(self):
"""Returns a generator over 2-element lists of indexes which must
be mutually exclusive in a solution (i.e. pairs of nodes which represent
the same path in opposite directions.)"""
for i in range(1, len(self.endpoints), 2):
yield [i, self.get_disj... |
def show_plot(plot, width=PREVIEW_WIDTH, height=PREVIEW_HEIGHT):
"""Preview a plot in a jupyter notebook.
Args:
plot (list): the plot to display (list of layers)
width (int): the width of the preview
height (int): the height of the preview
Returns:
An object that render... |
def calculate_view_box(layers, aspect_ratio, margin=DEFAULT_VIEW_BOX_MARGIN):
"""Calculates the size of the SVG viewBox to use.
Args:
layers (list): the layers in the image
aspect_ratio (float): the height of the output divided by the width
margin (float): minimum amount of buffer to ad... |
def _layer_to_path_gen(layer):
"""Generates an SVG path from a given layer.
Args:
layer (layer): the layer to convert
Yields:
str: the next component of the path
"""
draw = False
for x, y in zip(*layer):
if np.isnan(x) or np.isnan(y):
draw = False
el... |
def plot_to_svg(plot, width, height, unit=''):
"""Converts a plot (list of layers) into an SVG document.
Args:
plot (list): list of layers that make up the plot
width (float): the width of the resulting image
height (float): the height of the resulting image
unit (str): the unit... |
def write_plot(plot, filename, width=DEFAULT_PAGE_WIDTH, height=DEFAULT_PAGE_HEIGHT, unit=DEFAULT_PAGE_UNIT):
"""Writes a plot SVG to a file.
Args:
plot (list): a list of layers to plot
filename (str): the name of the file to write
width (float): the width of the output SVG
heig... |
def draw_layer(ax, layer):
"""Draws a layer on the given matplotlib axis.
Args:
ax (axis): the matplotlib axis to draw on
layer (layer): the layers to plot
"""
ax.set_aspect('equal', 'datalim')
ax.plot(*layer)
ax.axis('off') |
def map_texture_to_surface(texture, surface):
"""Returns values on a surface for points on a texture.
Args:
texture (texture): the texture to trace over the surface
surface (surface): the surface to trace along
Returns:
an array of surface heights for each point in the
text... |
def project_texture(texture_xy, texture_z, angle=DEFAULT_ANGLE):
"""Creates a texture by adding z-values to an existing texture and projecting.
When working with surfaces there are two ways to accomplish the same thing:
1. project the surface and map a texture to the projected surface
2. map a texture... |
def project_surface(surface, angle=DEFAULT_ANGLE):
"""Returns the height of the surface when projected at the given angle.
Args:
surface (surface): the surface to project
angle (float): the angle at which to project the surface
Returns:
surface: A projected surface.
"""
z_c... |
def project_texture_on_surface(texture, surface, angle=DEFAULT_ANGLE):
"""Maps a texture onto a surface, then projects to 2D and returns a layer.
Args:
texture (texture): the texture to project
surface (surface): the surface to project onto
angle (float): the projection angle in degrees... |
def _remove_hidden_parts(projected_surface):
"""Removes parts of a projected surface that are not visible.
Args:
projected_surface (surface): the surface to use
Returns:
surface: A projected surface.
"""
surface = np.copy(projected_surface)
surface[~_make_occlusion_mask(project... |
def project_and_occlude_texture(texture, surface, angle=DEFAULT_ANGLE):
"""Projects a texture onto a surface with occluded areas removed.
Args:
texture (texture): the texture to map to the projected surface
surface (surface): the surface to project
angle (float): the angle to project at... |
def make_lines_texture(num_lines=10, resolution=50):
"""Makes a texture consisting of a given number of horizontal lines.
Args:
num_lines (int): the number of lines to draw
resolution (int): the number of midpoints on each line
Returns:
A texture.
"""
x, y = np.meshgrid(
... |
def make_grid_texture(num_h_lines=10, num_v_lines=10, resolution=50):
"""Makes a texture consisting of a grid of vertical and horizontal lines.
Args:
num_h_lines (int): the number of horizontal lines to draw
num_v_lines (int): the number of vertical lines to draw
resolution (int): the n... |
def make_spiral_texture(spirals=6.0, ccw=False, offset=0.0, resolution=1000):
"""Makes a texture consisting of a spiral from the origin.
Args:
spirals (float): the number of rotations to make
ccw (bool): make spirals counter-clockwise (default is clockwise)
offset (float): if non-zero, ... |
def make_hex_texture(grid_size = 2, resolution=1):
"""Makes a texture consisting on a grid of hexagons.
Args:
grid_size (int): the number of hexagons along each dimension of the grid
resolution (int): the number of midpoints along the line of each hexagon
Returns:
A texture.
... |
def make_noise_surface(dims=DEFAULT_DIMS, blur=10, seed=None):
"""Makes a surface by generating random noise and blurring it.
Args:
dims (pair): the dimensions of the surface to create
blur (float): the amount of Gaussian blur to apply
seed (int): a random seed to use (optional)
... |
def make_gradients(dims=DEFAULT_DIMS):
"""Makes a pair of gradients to generate textures from numpy primitives.
Args:
dims (pair): the dimensions of the surface to create
Returns:
pair: A pair of surfaces.
"""
return np.meshgrid(
np.linspace(0.0, 1.0, dims[0]),
np.l... |
def make_sine_surface(dims=DEFAULT_DIMS, offset=0.5, scale=1.0):
"""Makes a surface from the 3D sine function.
Args:
dims (pair): the dimensions of the surface to create
offset (float): an offset applied to the function
scale (float): a scale applied to the sine frequency
Returns:
... |
def make_bubble_surface(dims=DEFAULT_DIMS, repeat=3):
"""Makes a surface from the product of sine functions on each axis.
Args:
dims (pair): the dimensions of the surface to create
repeat (int): the frequency of the waves is set to ensure this many
repetitions of the function
... |
def vrp_solver(path_graph, initial_solution=None, runtime_seconds=60):
"""Solve a path using or-tools' Vehicle Routing Problem solver.
Params:
path_graph the PathGraph representing the problem
initial_solution a solution to start with (list of indices, not
inclu... |
def init_controller(url):
"""Initialize a controller.
Provides a single global controller for applications that can't do this
themselves
"""
# pylint: disable=global-statement
global _VERA_CONTROLLER
created = False
if _VERA_CONTROLLER is None:
_VERA_CONTROLLER = VeraController(... |
def data_request(self, payload, timeout=TIMEOUT):
"""Perform a data_request and return the result."""
request_url = self.base_url + "/data_request"
return requests.get(request_url, timeout=timeout, params=payload) |
def get_simple_devices_info(self):
"""Get basic device info from Vera."""
j = self.data_request({'id': 'sdata'}).json()
self.scenes = []
items = j.get('scenes')
for item in items:
self.scenes.append(VeraScene(item, self))
if j.get('temperature'):
... |
def get_device_by_name(self, device_name):
"""Search the list of connected devices by name.
device_name param is the string name of the device
"""
# Find the device for the vera device name we are interested in
found_device = None
for device in self.get_devices():
... |
def get_device_by_id(self, device_id):
"""Search the list of connected devices by ID.
device_id param is the integer ID of the device
"""
# Find the device for the vera device name we are interested in
found_device = None
for device in self.get_devices():
if... |
def get_devices(self, category_filter=''):
"""Get list of connected devices.
category_filter param is an array of strings
"""
# pylint: disable=too-many-branches
# the Vera rest API is a bit rough so we need to make 2 calls to get
# all the info e need
self.get_... |
def refresh_data(self):
"""Refresh data from Vera device."""
j = self.data_request({'id': 'sdata'}).json()
self.temperature_units = j.get('temperature', 'C')
self.model = j.get('model')
self.version = j.get('version')
self.serial_number = j.get('serial_number')
... |
def map_services(self):
"""Get full Vera device service info."""
# the Vera rest API is a bit rough so we need to make 2 calls
# to get all the info e need
self.get_simple_devices_info()
j = self.data_request({'id': 'status', 'output_format': 'json'}).json()
service_map... |
def get_changed_devices(self, timestamp):
"""Get data since last timestamp.
This is done via a blocking call, pass NONE for initial state.
"""
if timestamp is None:
payload = {}
else:
payload = {
'timeout': SUBSCRIPTION_WAIT,
... |
def vera_request(self, **kwargs):
"""Perfom a vera_request for this device."""
request_payload = {
'output_format': 'json',
'DeviceNum': self.device_id,
}
request_payload.update(kwargs)
return self.vera_controller.data_request(request_payload) |
def set_service_value(self, service_id, set_name, parameter_name, value):
"""Set a variable on the vera device.
This will call the Vera api to change device state.
"""
payload = {
'id': 'lu_action',
'action': 'Set' + set_name,
'serviceId': service_id,... |
def call_service(self, service_id, action):
"""Call a Vera service.
This will call the Vera api to change device state.
"""
result = self.vera_request(id='action', serviceId=service_id,
action=action)
logger.debug("call_service: "
... |
def set_cache_value(self, name, value):
"""Set a variable in the local state dictionary.
This does not change the physical device. Useful if you want the
device state to refect a new value which has not yet updated drom
Vera.
"""
dev_info = self.json_state.get('deviceInf... |
def set_cache_complex_value(self, name, value):
"""Set a variable in the local complex state dictionary.
This does not change the physical device. Useful if you want the
device state to refect a new value which has not yet updated from
Vera.
"""
for item in self.json_sta... |
def get_complex_value(self, name):
"""Get a value from the service dictionaries.
It's best to use get_value if it has the data you require since
the vera subscription only updates data in dev_info.
"""
for item in self.json_state.get('states'):
if item.get('variable'... |
def get_strict_value(self, name):
"""Get a case-sensitive keys value from the dev_info area.
"""
dev_info = self.json_state.get('deviceInfo')
return dev_info.get(name, None) |
def refresh_complex_value(self, name):
"""Refresh a value from the service dictionaries.
It's best to use get_value / refresh if it has the data you need.
"""
for item in self.json_state.get('states'):
if item.get('variable') == name:
service_id = item.get('s... |
def refresh(self):
"""Refresh the dev_info data used by get_value.
Only needed if you're not using subscriptions.
"""
j = self.vera_request(id='sdata', output_format='json').json()
devices = j.get('devices')
for device_data in devices:
if device_data.get('id'... |
def update(self, params):
"""Update the dev_info data from a dictionary.
Only updates if it already exists in the device.
"""
dev_info = self.json_state.get('deviceInfo')
dev_info.update({k: params[k] for k in params if dev_info.get(k)}) |
def level(self):
"""Get level from vera."""
# Used for dimmers, curtains
# Have seen formats of 10, 0.0 and "0%"!
level = self.get_value('level')
try:
return int(float(level))
except (TypeError, ValueError):
pass
try:
return int... |
def set_switch_state(self, state):
"""Set the switch state, also update local state."""
self.set_service_value(
self.switch_service,
'Target',
'newTargetValue',
state)
self.set_cache_value('Status', state) |
def is_switched_on(self, refresh=False):
"""Get dimmer state.
Refresh data from Vera if refresh is True,
otherwise use local cache. Refresh is only needed if you're
not using subscriptions.
"""
if refresh:
self.refresh()
return self.get_brightness(ref... |
def get_brightness(self, refresh=False):
"""Get dimmer brightness.
Refresh data from Vera if refresh is True, otherwise use local cache.
Refresh is only needed if you're not using subscriptions.
Converts the Vera level property for dimmable lights from a percentage
to the 0 - 25... |
def set_brightness(self, brightness):
"""Set dimmer brightness.
Converts the Vera level property for dimmable lights from a percentage
to the 0 - 255 scale used by HA.
"""
percent = 0
if brightness > 0:
percent = round(brightness / 2.55)
self.set_ser... |
def get_color_index(self, colors, refresh=False):
"""Get color index.
Refresh data from Vera if refresh is True, otherwise use local cache.
"""
if refresh:
self.refresh_complex_value('SupportedColors')
sup = self.get_complex_value('SupportedColors')
if sup i... |
def get_color(self, refresh=False):
"""Get color.
Refresh data from Vera if refresh is True, otherwise use local cache.
"""
if refresh:
self.refresh_complex_value('CurrentColor')
ci = self.get_color_index(['R', 'G', 'B'], refresh)
cur = self.get_complex_valu... |
def set_color(self, rgb):
"""Set dimmer color.
"""
target = ','.join([str(c) for c in rgb])
self.set_service_value(
self.color_service,
'ColorRGB',
'newColorRGBTarget',
target)
rgbi = self.get_color_index(['R', 'G', 'B'])
... |
def set_armed_state(self, state):
"""Set the armed state, also update local state."""
self.set_service_value(
self.security_sensor_service,
'Armed',
'newArmedValue',
state)
self.set_cache_value('Armed', state) |
def is_switched_on(self, refresh=False):
"""Get armed state.
Refresh data from Vera if refresh is True, otherwise use local cache.
Refresh is only needed if you're not using subscriptions.
"""
if refresh:
self.refresh()
val = self.get_value('Armed')
r... |
def is_open(self, refresh=False):
"""Get curtains state.
Refresh data from Vera if refresh is True, otherwise use local cache.
Refresh is only needed if you're not using subscriptions.
"""
if refresh:
self.refresh()
return self.get_level(refresh) > 0 |
def set_level(self, level):
"""Set open level of the curtains.
Scale is 0-100
"""
self.set_service_value(
self.dimmer_service,
'LoadLevelTarget',
'newLoadlevelTarget',
level)
self.set_cache_value('level', level) |
def get_last_user(self, refresh=False):
"""Get the last used PIN user id"""
if refresh:
self.refresh_complex_value('sl_UserCode')
val = self.get_complex_value("sl_UserCode")
# Syntax string: UserID="<pin_slot>" UserName="<pin_code_name>"
# See http://wiki.micasaverde.... |
def get_pin_codes(self, refresh=False):
"""Get the list of PIN codes
Codes can also be found with self.get_complex_value('PinCodes')
"""
if refresh:
self.refresh()
val = self.get_value("pincodes")
# val syntax string: <VERSION=3>next_available_user_code_id\t... |
def set_temperature(self, temp):
"""Set current goal temperature / setpoint"""
self.set_service_value(
self.thermostat_setpoint,
'CurrentSetpoint',
'NewCurrentSetpoint',
temp)
self.set_cache_value('setpoint', temp) |
def get_current_goal_temperature(self, refresh=False):
"""Get current goal temperature / setpoint"""
if refresh:
self.refresh()
try:
return float(self.get_value('setpoint'))
except (TypeError, ValueError):
return None |
def get_current_temperature(self, refresh=False):
"""Get current temperature"""
if refresh:
self.refresh()
try:
return float(self.get_value('temperature'))
except (TypeError, ValueError):
return None |
def set_hvac_mode(self, mode):
"""Set the hvac mode"""
self.set_service_value(
self.thermostat_operating_service,
'ModeTarget',
'NewModeTarget',
mode)
self.set_cache_value('mode', mode) |
def set_fan_mode(self, mode):
"""Set the fan mode"""
self.set_service_value(
self.thermostat_fan_service,
'Mode',
'NewMode',
mode)
self.set_cache_value('fanmode', mode) |
def get_last_scene_id(self, refresh=False):
"""Get last scene id.
Refresh data from Vera if refresh is True, otherwise use local cache.
Refresh is only needed if you're not using subscriptions.
"""
if refresh:
self.refresh_complex_value('LastSceneID')
sel... |
def get_last_scene_time(self, refresh=False):
"""Get last scene time.
Refresh data from Vera if refresh is True, otherwise use local cache.
Refresh is only needed if you're not using subscriptions.
"""
if refresh:
self.refresh_complex_value('LastSceneTime')
v... |
def vera_request(self, **kwargs):
"""Perfom a vera_request for this scene."""
request_payload = {
'output_format': 'json',
'SceneNum': self.scene_id,
}
request_payload.update(kwargs)
return self.vera_controller.data_request(request_payload) |
def activate(self):
"""Activate a Vera scene.
This will call the Vera api to activate a scene.
"""
payload = {
'id': 'lu_action',
'action': 'RunScene',
'serviceId': self.scene_service
}
result = self.vera_request(**payload)
log... |
def refresh(self):
"""Refresh the data used by get_value.
Only needed if you're not using subscriptions.
"""
j = self.vera_request(id='sdata', output_format='json').json()
scenes = j.get('scenes')
for scene_data in scenes:
if scene_data.get('id') == self.scen... |
def register(self, device, callback):
"""Register a callback.
device: device to be updated by subscription
callback: callback for notification of changes
"""
if not device:
logger.error("Received an invalid device: %r", device)
return
logger.debu... |
def unregister(self, device, callback):
"""Remove a registered a callback.
device: device that has the subscription
callback: callback used in original registration
"""
if not device:
logger.error("Received an invalid device: %r", device)
return
... |
def start(self):
"""Start a thread to handle Vera blocked polling."""
self._poll_thread = threading.Thread(target=self._run_poll_server,
name='Vera Poll Thread')
self._poll_thread.deamon = True
self._poll_thread.start() |
def format_timestamp(ts):
"""
Format the UTC timestamp for Elasticsearch
eg. 2014-07-09T08:37:18.000Z
@see https://docs.python.org/2/library/time.html#time.strftime
"""
tz_info = tz.tzutc()
return datetime.fromtimestamp(ts, tz=tz_info).strftime("%Y-%m-%dT%H:%M:%S.... |
def _pick_level(cls, btc_amount):
"""
Choose between small, medium, large, ... depending on the
amount specified.
"""
for size, level in cls.TICKER_LEVEL:
if btc_amount < size:
return level
return cls.TICKER_LEVEL[-1][1] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.