prompt
large_stringlengths
72
9.34k
completion
large_stringlengths
0
7.61k
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
return np.logical_not(self._mapped_eq(other))
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
return super().__ne__(other)
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
mapping = getattr(args[0], 'mapping', {})
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
return AliasCSRMatrix(result, mapping=self.mapping)
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
return result
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__new__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__array_finalize__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
_mapped_eq
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__eq__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__ne__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__init__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
format
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
format
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
mapping
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
tocoo
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__getitem__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__init__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__bool__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__array__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__init__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__str__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__eq__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__ne__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__hash__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
eye
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
first
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__eq__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__ne__
<|file_name|>alias.py<|end_file_name|><|fim▁begin|>import numpy as np from scipy.sparse import csr_matrix class AliasArray(np.ndarray): """An ndarray with a mapping of values to user-friendly names -- see example This ndarray subclass enables comparing sub_id and hop_id arrays directly with their friendl...
__hash__
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' ...
'This is cell A1 in Sheet 1', 'This is cell G5']
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): <|fim_middle|> def test_empty_string(datadir): datadir.j...
datadir.join('reader').chdir() src = 'sharedStrings.xml' with open(src) as content: assert read_string_table(content.read()) == [ 'This is cell A1 in Sheet 1', 'This is cell G5']
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' ...
datadir.join('reader').chdir() src = 'sharedStrings-emptystring.xml' with open(src) as content: assert read_string_table(content.read()) == ['Testing empty cell', '']
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' ...
datadir.join('reader').chdir() src = 'shared-strings-rich.xml' with open(src) as content: assert read_string_table(content.read()) == [ 'Welcome', 'to the best shop in town', " let's play "]
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' ...
from openpyxl.writer.strings import write_string_table datadir.join("reader").chdir() table = ['This is cell A1 in Sheet 1', 'This is cell G5'] content = write_string_table(table) with open('sharedStrings.xml') as expected: diff = compare_xml(content, expected.read()) assert diff is...
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def <|fim_middle|>(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' with o...
test_read_string_table
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' ...
test_empty_string
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' ...
test_formatted_string_table
<|file_name|>test_strings.py<|end_file_name|><|fim▁begin|># Copyright (c) 2010-2015 openpyxl # package imports from openpyxl.reader.strings import read_string_table from openpyxl.tests.helper import compare_xml def test_read_string_table(datadir): datadir.join('reader').chdir() src = 'sharedStrings.xml' ...
test_write_string_table
<|file_name|>signals.py<|end_file_name|><|fim▁begin|>from django.dispatch import Signal user_email_bounced = Signal() # args: ['bounce', 'should_deactivate'] email_bounced = Signal() # args: ['bounce', 'should_deactivate']<|fim▁hole|><|fim▁end|>
email_unsubscribed = Signal() # args: ['email', 'reference']
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
u = XMLRPCSerializer(model = user) u = u.serialize_model() if u.get('password'): del u['password'] return u
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
""" Description: Performs a search and returns the resulting list of test cases. Params: $query - Hash: keys must match valid search fields. +------------------------------------------------------------------+ | Case Search Parameters | ...
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
""" Description: Used to load an existing test case from the database. Params: $id - Integer/String: An integer representing the ID in the database Returns: A blessed User object Hash Example: >>> User.get(2206) """ return get_user_dict(User.objects.get(pk = id))
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
""" Description: Get the information of myself. Returns: A blessed User object Hash Example: >>> User.get_me() """ return get_user_dict(request.user)
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
""" Description: Updates the fields of the selected user. it also can change the informations of other people if you have permission. Params: $values - Hash of keys matching TestCase fields and the new values to set each field to. $id ...
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
del u['password']
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
u = User.objects.get(pk = id)
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
u = request.user
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
raise PermissionDenied
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
if f == 'password': if not request.user.has_perm('auth.change_changeuser') and not values.get('old_password'): raise PermissionDenied('Old password is required') if not request.user.has_perm('auth.change_changeuser') and not u.check_password(values.get('o...
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
if not request.user.has_perm('auth.change_changeuser') and not values.get('old_password'): raise PermissionDenied('Old password is required') if not request.user.has_perm('auth.change_changeuser') and not u.check_password(values.get('old_password')): ...
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
raise PermissionDenied('Old password is required')
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
raise PermissionDenied('Password is incorrect')
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
setattr(u, f, values[f])
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
get_user_dict
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
filter
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
get
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
get_me
<|file_name|>user.py<|end_file_name|><|fim▁begin|># -*- coding: utf-8 -*- # # Nitrate is copyright 2010 Red Hat, Inc. # # Nitrate is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 2 of the License...
update
<|file_name|>server_web.py<|end_file_name|><|fim▁begin|># A basic web server using sockets import socket PORT = 8090 MAX_OPEN_REQUESTS = 5 def process_client(clientsocket): print(clientsocket) data = clientsocket.recv(1024) print(data) web_contents = "<h1>Received</h1>" f = open("myhtml.html", "r") w...
serversocket.bind((ip, PORT)) # become a server socket # MAX_OPEN_REQUESTS connect requests before refusing outside connections serversocket.listen(MAX_OPEN_REQUESTS)
<|file_name|>server_web.py<|end_file_name|><|fim▁begin|># A basic web server using sockets import socket PORT = 8090 MAX_OPEN_REQUESTS = 5 def process_client(clientsocket): <|fim_middle|> # create an INET, STREAMing socket serversocket = socket.socket(socket.AF_INET, socket.SOCK...
print(clientsocket) data = clientsocket.recv(1024) print(data) web_contents = "<h1>Received</h1>" f = open("myhtml.html", "r") web_contents = f.read() f.close() web_headers = "HTTP/1.1 200" web_headers += "\n" + "Content-Type: text/html" web_headers += "\n" + "Content-Length: %i" % len(str.e...
<|file_name|>server_web.py<|end_file_name|><|fim▁begin|># A basic web server using sockets import socket PORT = 8090 MAX_OPEN_REQUESTS = 5 def <|fim_middle|>(clientsocket): print(clientsocket) data = clientsocket.recv(1024) print(data) web_contents = "<h1>Received</h1>" f = open("myhtml.html", "r") w...
process_client
<|file_name|>win32_aclui.py<|end_file_name|><|fim▁begin|># pylint:disable=line-too-long import logging from ...sim_type import SimTypeFunction, SimTypeShort, SimTypeInt, SimTypeLong, SimTypeLongLong, SimTypeDouble, SimTypeFloat, SimTypePointer, SimTypeChar, SimStruct, SimTypeFixedSizeArray, Sim...
lib.set_prototypes(prototypes)
<|file_name|>__init__.py<|end_file_name|><|fim▁begin|><|fim▁hole|>__package__ = 'archivebox.core'<|fim▁end|>
<|file_name|>utils.py<|end_file_name|><|fim▁begin|>import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > 0...
if src == CURRENCY_EUR and dst == CURRENCY_USD:
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): <|fim_middle|> def fo...
assert decimal_places > 0 factor = 1.0 ** decimal_places sign = -1 if value < 0 else 1 return int(value * factor + sign * (0 if down else 0.5)) / factor
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
append_comma = lambda match_object: "%s," % match_object.group(0) value = "%.2f" % float(value) value = re.sub("(\d)(?=(\d{3})+\.)", append_comma, value) return value
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
price = float(price) return format_number(round_number(price) if round_price else price)
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
return '%s %s' % (format_price(price), dict(CURRENCIES)[currency])
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
currency = session.get(CURRENCY_SESSION_KEY) or DEFAULT_CURRENCY return int(currency)
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
if src == dst: return lambda p: p name = lambda c: CURRENCY_NAMES[c] if src == CURRENCY_UAH: return lambda p: p / getattr(rates, name(dst)) if dst == CURRENCY_UAH: return lambda p: p * getattr(rates, name(src)) if src == CURRENCY_USD and dst == CURRENCY_EUR: retur...
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
return lambda p: p
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
return lambda p: p / getattr(rates, name(dst))
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
return lambda p: p * getattr(rates, name(src))
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
return lambda p: p * rates.usd_eur
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
return lambda p: p / rates.usd_eur
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def <|fim_middle|>(value, decimal_places=2, down=False): assert decimal_places ...
round_number
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
format_number
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
format_price
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
format_printable_price
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
get_currency_from_session
<|file_name|>utils.py<|end_file_name|><|fim▁begin|> import re from exchange.constants import ( CURRENCIES, CURRENCY_NAMES, DEFAULT_CURRENCY, CURRENCY_EUR, CURRENCY_UAH, CURRENCY_USD, CURRENCY_SESSION_KEY) def round_number(value, decimal_places=2, down=False): assert decimal_places > ...
get_price_factory
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
from nova.objects import base from nova.objects import fields
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
"""Data representing additional resources related to a migration. Some resources cannot be calculated from knowing the flavor alone for the purpose of resources tracking, but need to be persisted at the time the claim was made, for subsequent resource tracking runs to be consistent. MigrationContex...
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
target_version = versionutils.convert_version_to_tuple(target_version) if target_version < (1, 1): primitive.pop('old_pci_devices', None) primitive.pop('new_pci_devices', None) primitive.pop('old_pci_requests', None) primitive.pop('new_pci_requests', None)
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
primitive = jsonutils.loads(db_obj) return cls.obj_from_primitive(primitive)
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
db_extra = db.instance_extra_get_by_instance_uuid( context, instance_uuid, columns=['migration_context']) if not db_extra: raise exception.MigrationContextNotFound( instance_uuid=instance_uuid) if db_extra['migration_context'] is None: ret...
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
primitive.pop('old_pci_devices', None) primitive.pop('new_pci_devices', None) primitive.pop('old_pci_requests', None) primitive.pop('new_pci_requests', None)
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
raise exception.MigrationContextNotFound( instance_uuid=instance_uuid)
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
return None
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
obj_make_compatible
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
obj_from_db_obj
<|file_name|>migration_context.py<|end_file_name|><|fim▁begin|># Copyright 2015 Red Hat Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/lice...
get_by_instance_uuid
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including wi...
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including wi...
try: return int(value) except ValueError: pass matches = re.match(ISO8601, value) if not matches: raise ArgumentTypeError("Argument is not a valid UNIX or ISO8601 " "timestamp.") return int(datetime.datetime( *[int(m) for m in matches.g...
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including wi...
value = value.replace("#", "") if not re.match(r"^[a-f0-9]{6}$", value): raise ArgumentTypeError("Argument is not a valid hex value.") return value
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including wi...
raise ArgumentTypeError("Argument is not a valid UNIX or ISO8601 " "timestamp.")
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including wi...
raise ArgumentTypeError("Argument is not a valid hex value.")
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including wi...
message[param] = value
<|file_name|>slack.py<|end_file_name|><|fim▁begin|>#!/usr/bin/env python3 # # Copyright (c) 2017 Nick Douma # # Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), # to deal in the Software without restriction, including wi...
attachment[param] = value