uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
ebf7bee96f8b062f4dadeb51
train
class
class SetupDataSetList(SDL): implements(ISetupDataSetList) def __call__(self): return SDL.__call__(self, projectname="bika.lims")
class SetupDataSetList(SDL):
implements(ISetupDataSetList) def __call__(self): return SDL.__call__(self, projectname="bika.lims")
'%s.%s' % (path, e) if os.path.isfile(out): return open(out, "rb").read() raise IOError("File not found: %s. Allowed extensions: %s" % (path, ','.join(allowed_ext))) class SetupDataSetList(SDL):
63
64
38
7
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
SetupDataSetList
SetupDataSetList
60
65
60
61
f8b840ad19511e7e0b19968fc764a03b08f07e13
bigcode/the-stack
train
ff8a674eeeb1b8469e6b1c13
train
class
class Instruments(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_instruments bsc = getToolByName(self.context, 'bika_setup_catalog') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): if ('Type' not in row ...
class Instruments(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_instruments bsc = getToolByName(self.context, 'bika_setup_catalog') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): if ('Type' not in row or 'Supplier' not in row ...
Manufacturers(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_manufacturers for row in self.get_rows(3): obj = _createObjectByType("Manufacturer", folder, tmpID()) if row['title']: obj.edit( title=row['title'],...
202
202
676
6
196
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Instruments
Instruments
688
764
688
689
6665c286905054c6a5eb98b448cfd52093ddbca0
bigcode/the-stack
train
013fe144a61ddaa262499469
train
function
def Float(thing): try: f = float(thing) except ValueError: f = 0.0 return f
def Float(thing):
try: f = float(thing) except ValueError: f = 0.0 return f
(column, None): message = _("%s has no '%s' column." % (name, column)) raise Exception(t(message)) def Int(thing): try: f = int(thing) except ValueError: f = 0 return f def Float(thing):
64
64
32
5
58
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Float
Float
40
45
40
40
2b777fb79d5ef6ccac3f4233ac468650c1e98e23
bigcode/the-stack
train
4570eb2bf274ef25d2072168
train
class
class Containers(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_containers bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("Conta...
class Containers(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_containers bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("Container", folder, tmpID()) ob...
minutes': int(row['RetentionPeriod_minutes'] and row['RetentionPeriod_minutes'] or 0), } obj.edit(title=row['title'], description=row.get('description', ''), RetentionPeriod=RP) obj.unmarkCreationFlag() renameAfterCreation(obj) c...
64
64
214
6
58
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Containers
Containers
578
602
578
579
a6b2bc6492b4f9dc5b814bad348fc6f7661db671
bigcode/the-stack
train
7afafeb08396e254b1ab2def
train
class
class Methods(WorksheetImporter): def Import(self): folder = self.context.methods bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if row['title']: calculation = self.get_object(bsc, 'Calculation', row.get('Calculation_title'))...
class Methods(WorksheetImporter):
def Import(self): folder = self.context.methods bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if row['title']: calculation = self.get_object(bsc, 'Calculation', row.get('Calculation_title')) obj = _createObjec...
obj.unmarkCreationFlag() renameAfterCreation(obj) elif not row.get('title', None): logger.warning("Error in in " + self.sheetname + ". Missing Title field") elif not row.get('Department_title', None): logger.warning("Error in " + self.sheetname + ...
105
106
356
6
99
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Methods
Methods
1,197
1,236
1,197
1,198
ca771881110ca32ee6fcfd8534d128fde6d575f5
bigcode/the-stack
train
87ecd33c5b2ea7447fe36fb7
train
class
class Setup(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') values = {} for row in self.get_rows(3): values[row['Field']] = row['Value'] DSL = { 'days': int(values['DefaultSampleLifetime_days'] and values['Defaul...
class Setup(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') values = {} for row in self.get_rows(3): values[row['Field']] = row['Value'] DSL = { 'days': int(values['DefaultSampleLifetime_days'] and values['DefaultSampleLifetime_days'] or 0), ...
WorksheetTemplate_title']] = [] self.wst_services[ row['WorksheetTemplate_title']].append(service.UID()) def Import(self): self.load_wst_services() self.load_wst_layouts() folder = self.context.bika_setup.bika_worksheettemplates for row in self.get_rows(3...
154
154
514
6
148
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Setup
Setup
1,842
1,889
1,842
1,843
44abea542d0e822988a41e0467ccb316dda5ac56
bigcode/the-stack
train
7019edbfbd59d1071d8b1dcf
train
class
class Instrument_Schedule(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['instrument'] or not row['title'] or not row['type']: continue folder = self.get_object(bsc, 'Instr...
class Instrument_Schedule(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['instrument'] or not row['title'] or not row['type']: continue folder = self.get_object(bsc, 'Instrument', row.get('instrument')) if f...
''), DownTo=row.get('downto', ''), Maintainer=row.get('maintaner', ''), Considerations=row.get('considerations', ''), WorkPerformed=row.get('workperformed', ''), Remarks=row.get('remarks', ''), Cost=...
88
88
294
8
80
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Instrument_Schedule
Instrument_Schedule
969
999
969
970
52118e91fca53b65237e376d4932d13a08aab4ca
bigcode/the-stack
train
844bf071a4577ca848c16e57
train
class
class Sample_Point_Sample_Types(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): sampletype = self.get_object(bsc, 'SampleType', ro...
class Sample_Point_Sample_Types(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): sampletype = self.get_object(bsc, 'SampleType', row.get('SampleType_title')) samplepoint = ...
'], ) sampletype = self.get_object(bsc, 'SampleType', row.get('SampleType_title')) if sampletype: obj.setSampleTypes([sampletype, ]) obj.unmarkCreationFlag() renameAfterCreation(obj) class Sample_Point_S...
64
64
158
11
53
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Sample_Point_Sample_Types
Sample_Point_Sample_Types
1,105
1,125
1,105
1,106
400301211201cdb798ba132a67744c8f3d135da4
bigcode/the-stack
train
58d8cb1c33ad6ddcfa11d2fe
train
class
class Instrument_Maintenance_Tasks(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['instrument'] or not row['title'] or not row['type']: continue folder = self.get_object(b...
class Instrument_Maintenance_Tasks(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['instrument'] or not row['title'] or not row['type']: continue folder = self.get_object(bsc, 'Instrument',row.get('instrument')) if f...
DocumentID=row_dict.get('DocumentID', ''), DocumentVersion=row_dict.get('DocumentVersion', ''), DocumentLocation=row_dict.get('DocumentLocation', ''), DocumentType=row_dict.get('DocumentType', ''), File=file_data ...
75
75
251
11
64
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Instrument_Maintenance_Tasks
Instrument_Maintenance_Tasks
936
966
936
937
5006e1bfd98c5c96fa12d2f8e05b8affcd62cdcf
bigcode/the-stack
train
4d81388d116985a3658d86cd
train
class
class Preservations(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_preservations for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("Preservation", folder, tmpID()) RP = { ...
class Preservations(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_preservations for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("Preservation", folder, tmpID()) RP = { 'days': int(row['RetentionPeriod_days...
if not row['title']: continue obj = _createObjectByType("ContainerType", folder, tmpID()) obj.edit(title=row['title'], description=row.get('description', '')) obj.unmarkCreationFlag() renameAfterCreation(obj) class Preservations(Works...
64
64
172
8
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Preservations
Preservations
557
575
557
558
c77d5b1704d3bf608a74afcb9c0798da004ca1b4
bigcode/the-stack
train
6f20a630099de9f41fae6b7b
train
class
class Analysis_Services(WorksheetImporter): def load_interim_fields(self): # preload AnalysisService InterimFields sheet sheetname = 'AnalysisService InterimFields' worksheet = self.workbook.get_sheet_by_name(sheetname) if not worksheet: return self.service_inter...
class Analysis_Services(WorksheetImporter):
def load_interim_fields(self): # preload AnalysisService InterimFields sheet sheetname = 'AnalysisService InterimFields' worksheet = self.workbook.get_sheet_by_name(sheetname) if not worksheet: return self.service_interims = {} rows = self.get_rows(3, work...
() folder = self.context.bika_setup.bika_calculations for row in self.get_rows(3): if not row['title']: continue calc_title = row['title'] calc_interims = self.interim_fields.get(calc_title, []) formula = row['Formula'] # scan f...
256
256
2,497
8
248
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Analysis_Services
Analysis_Services
1,309
1,557
1,309
1,310
9c9dd3528bf85f5a1359a441f373c24e03e28a64
bigcode/the-stack
train
de870bfbfbba2d9f12c3b57c
train
function
def Int(thing): try: f = int(thing) except ValueError: f = 0 return f
def Int(thing):
try: f = int(thing) except ValueError: f = 0 return f
(**kwargs)[0].getObject() def check_for_required_columns(name, data, required): for column in required: if not data.get(column, None): message = _("%s has no '%s' column." % (name, column)) raise Exception(t(message)) def Int(thing):
64
64
30
5
59
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Int
Int
33
38
33
33
f89926ed8e9675a413b538405a00328fbe66c734
bigcode/the-stack
train
9412738bfa6e6e7f8bbef2f6
train
class
class Reference_Definitions(WorksheetImporter): def load_reference_definition_results(self): sheetname = 'Reference Definition Results' worksheet = self.workbook.get_sheet_by_name(sheetname) if not worksheet: sheetname = 'Reference Definition Values' worksheet = self...
class Reference_Definitions(WorksheetImporter):
def load_reference_definition_results(self): sheetname = 'Reference Definition Results' worksheet = self.workbook.get_sheet_by_name(sheetname) if not worksheet: sheetname = 'Reference Definition Values' worksheet = self.workbook.get_sheet_by_name(sheetname) ...
_title')) obj = _createObjectByType("ARTemplate", folder, tmpID()) obj.edit( title=row['title'], description=row.get('description', ''), Remarks=row.get('Remarks', ''), ReportDryMatter=bool(row['ReportDryMatter'])) obj....
110
110
368
8
102
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Reference_Definitions
Reference_Definitions
1,747
1,787
1,747
1,748
56681d983910dccd3b1d4dd6f2830f1c91b0b783
bigcode/the-stack
train
98206494655beb2931ef53a4
train
class
class Lab_Contacts(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_labcontacts portal_groups = getToolByName(self.context, 'portal_groups') portal_registration = getToolByName( self.context, 'portal_registration') for row in self.get_rows(3):...
class Lab_Contacts(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_labcontacts portal_groups = getToolByName(self.context, 'portal_groups') portal_registration = getToolByName( self.context, 'portal_registration') for row in self.get_rows(3): # Create LabContact ...
name) else: file_data = None laboratory.edit( Name=values['Name'], LabURL=values['LabURL'], Confidence=values['Confidence'], LaboratoryAccredited=self.to_bool(values['LaboratoryAccredited']), AccreditationBodyLong=values['Accredita...
155
155
517
8
147
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Lab_Contacts
Lab_Contacts
329
401
329
330
6ed73e7bc8c2dc24ce7365389bf53e90eeb263aa
bigcode/the-stack
train
abf1203335f9f636835d668b
train
class
class Storage_Locations(WorksheetImporter): def Import(self): setup_folder = self.context.bika_setup.bika_storagelocations bsc = getToolByName(self.context, 'bika_setup_catalog') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): if not row['...
class Storage_Locations(WorksheetImporter):
def Import(self): setup_folder = self.context.bika_setup.bika_storagelocations bsc = getToolByName(self.context, 'bika_setup_catalog') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): if not row['Address']: continue ...
not in sampletypes: sampletypes.append(sampletype) samplepoint.setSampleTypes(sampletypes) samplepoints = sampletype.getSamplePoints() if samplepoint not in samplepoints: samplepoints.append(samplepoint) sampletype.setSamplePoints...
64
64
213
8
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Storage_Locations
Storage_Locations
1,127
1,152
1,127
1,128
f70bd9901d66fb2bd282e3e8d720c69c5a80af2c
bigcode/the-stack
train
f721ddb8515eda6940f938eb
train
class
class Lab_Information(WorksheetImporter): def Import(self): laboratory = self.context.bika_setup.laboratory values = {} for row in self.get_rows(3): values[row['Field']] = row['Value'] if values['AccreditationBodyLogo']: path = resource_filename( ...
class Lab_Information(WorksheetImporter):
def Import(self): laboratory = self.context.bika_setup.laboratory values = {} for row in self.get_rows(3): values[row['Field']] = row['Value'] if values['AccreditationBodyLogo']: path = resource_filename( self.dataset_project, ...
groups for row in self.get_rows(3): if 'title' in row and row['title']: obj = _createObjectByType("SubGroup", folder, tmpID()) obj.edit(title=row['title'], description=row['description'], SortKey=row['SortKey']) ...
84
84
282
8
76
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Lab_Information
Lab_Information
291
326
291
292
2b33e286b7c970be19433ab4b26a98f4f40dd8f9
bigcode/the-stack
train
12054c99faa0632a403cd63e
train
class
class Sub_Groups(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_subgroups for row in self.get_rows(3): if 'title' in row and row['title']: obj = _createObjectByType("SubGroup", folder, tmpID()) obj.edit(title=row['title'], ...
class Sub_Groups(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_subgroups for row in self.get_rows(3): if 'title' in row and row['title']: obj = _createObjectByType("SubGroup", folder, tmpID()) obj.edit(title=row['title'], description=row[...
one object found for %s" % contentFilter) return None elif len(brains) == 0: logger.info("No objects found for %s" % contentFilter) return None else: return brains[0].getObject() class Sub_Groups(WorksheetImporter):
64
64
100
8
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Sub_Groups
Sub_Groups
277
288
277
278
9a3bb3e01a81cd748b34e870a062b0d743a3d2b3
bigcode/the-stack
train
11a62add59ff4e5a9b27107c
train
class
class WorksheetImporter: """Use this as a base, for normal tabular data sheet imports. """ def __init__(self, context): self.adapter_context = context def __call__(self, lsd, workbook, dataset_project, dataset_name): self.lsd = lsd self.context = lsd.context self.workb...
class WorksheetImporter:
"""Use this as a base, for normal tabular data sheet imports. """ def __init__(self, context): self.adapter_context = context def __call__(self, lsd, workbook, dataset_project, dataset_name): self.lsd = lsd self.context = lsd.context self.workbook = workbook sel...
(t(message)) def Int(thing): try: f = int(thing) except ValueError: f = 0 return f def Float(thing): try: f = float(thing) except ValueError: f = 0.0 return f def read_file(path): if os.path.isfile(path): return open(path, "rb").read() allowed_e...
256
256
1,617
4
252
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
WorksheetImporter
WorksheetImporter
68
274
68
69
af230ffcb5450974af5a19a2ac73e23dd400d3f4
bigcode/the-stack
train
379325584cd9309fa64d902a
train
class
class Batch_Labels(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_batchlabels for row in self.get_rows(3): if row['title']: obj = _createObjectByType("BatchLabel", folder, tmpID()) obj.edit(title=row['title']) ...
class Batch_Labels(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_batchlabels for row in self.get_rows(3): if row['title']: obj = _createObjectByType("BatchLabel", folder, tmpID()) obj.edit(title=row['title']) obj.unmarkCreationFlag() ...
['title']: continue obj = _createObjectByType("SampleMatrix", folder, tmpID()) obj.edit( title=row['title'], description=row.get('description', '') ) obj.unmarkCreationFlag() renameAfterCreation(obj) class Batch_...
64
64
80
8
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Batch_Labels
Batch_Labels
1,018
1,027
1,018
1,019
a5a6fe3ea43904f2081f1c70f13fbdc8352c6404
bigcode/the-stack
train
f015aa7e23265e52373aa951
train
class
class Worksheet_Templates(WorksheetImporter): def load_wst_layouts(self): sheetname = 'Worksheet Template Layouts' worksheet = self.workbook.get_sheet_by_name(sheetname) self.wst_layouts = {} if not worksheet: return for row in self.get_rows(3, worksheet=workshee...
class Worksheet_Templates(WorksheetImporter):
def load_wst_layouts(self): sheetname = 'Worksheet Template Layouts' worksheet = self.workbook.get_sheet_by_name(sheetname) self.wst_layouts = {} if not worksheet: return for row in self.get_rows(3, worksheet=worksheet): if row['WorksheetTemplate_title...
_reference_definition_results() folder = self.context.bika_setup.bika_referencedefinitions for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("ReferenceDefinition", folder, tmpID()) obj.edit( title=row[...
129
129
433
8
121
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Worksheet_Templates
Worksheet_Templates
1,790
1,839
1,790
1,791
4b5b93028bc52b31efc0da8634e5848fdda87997
bigcode/the-stack
train
b9b9c7ea3ec1fb5077362bae
train
class
class Suppliers(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_suppliers for row in self.get_rows(3): obj = _createObjectByType("Supplier", folder, tmpID()) if row['Name']: obj.edit( Name=row.get('Name', ''), ...
class Suppliers(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_suppliers for row in self.get_rows(3): obj = _createObjectByType("Supplier", folder, tmpID()) if row['Name']: obj.edit( Name=row.get('Name', ''), TaxNumber=row.get(...
obj.setContainerType(ct) if row['Preservation_title']: pres = self.get_object(bsc, 'Preservation',row.get('Preservation_title','')) if pres: obj.setPreservation(pres) obj.unmarkCreationFlag() renameAfterCreation(obj) class Supplier...
66
66
220
6
60
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Suppliers
Suppliers
605
629
605
606
3fe019949e9e41650a8c350dc6978e9ed31441d3
bigcode/the-stack
train
dc72139520059beb2a1a8eff
train
class
class Sample_Matrices(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_samplematrices for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("SampleMatrix", folder, tmpID()) obj.edit( ...
class Sample_Matrices(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_samplematrices for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("SampleMatrix", folder, tmpID()) obj.edit( title=row['title'], ...
': row.get('repeatuntil')} ] obj.edit( title=row['title'], Type=row['type'], ScheduleCriteria=criteria, Considerations=row.get('considerations', ''), ) obj.unmarkCreationFlag()...
64
64
97
8
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Sample_Matrices
Sample_Matrices
1,002
1,015
1,002
1,003
8b08151f6d9f662ad16b64c8a295b9fa63e661c8
bigcode/the-stack
train
2b611f8c6fc3159d7a40fafa
train
class
class Analysis_Profiles(WorksheetImporter): def load_analysis_profile_services(self): sheetname = 'Analysis Profile Services' worksheet = self.workbook.get_sheet_by_name(sheetname) self.profile_services = {} if not worksheet: return bsc = getToolByName(self.conte...
class Analysis_Profiles(WorksheetImporter):
def load_analysis_profile_services(self): sheetname = 'Analysis Profile Services' worksheet = self.workbook.get_sheet_by_name(sheetname) self.profile_services = {} if not worksheet: return bsc = getToolByName(self.context, 'bika_setup_catalog') for row in ...
][title]["sampletype"] resultsrange = bucket[parent][title]["resultsrange"] if st: st_uid = bsc(portal_type="SampleType", title=safe_unicode(st))[0].UID obj = _createObjectByType("AnalysisSpec", folder, tmpID()) obj.edit(title=title) ...
110
110
367
8
102
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Analysis_Profiles
Analysis_Profiles
1,623
1,659
1,623
1,624
fc071672b8567950ff2f3ab4b27ca9b575c82db8
bigcode/the-stack
train
0e11cf1b85227ce8036370b9
train
class
class Lab_Departments(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_departments bsc = getToolByName(self.context, 'bika_setup_catalog') lab_contacts = [o.getObject() for o in bsc(portal_type="LabContact")] for row in self.get_rows(3): if row...
class Lab_Departments(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_departments bsc = getToolByName(self.context, 'bika_setup_catalog') lab_contacts = [o.getObject() for o in bsc(portal_type="LabContact")] for row in self.get_rows(3): if row['title']: obj = _createObj...
member._addRole(role_id) # If user is in LabManagers, add Owner local role on clients # folder if 'LabManager' in group_ids: self.context.clients.manage_setLocalRoles( username, ['Owner', ]) class Lab_Dep...
63
64
209
9
54
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Lab_Departments
Lab_Departments
404
427
404
405
58ad98a48afce3cd6f7db0d2e780272917386a77
bigcode/the-stack
train
7a86748903f2f5936ed65391
train
function
def read_file(path): if os.path.isfile(path): return open(path, "rb").read() allowed_ext = ['pdf', 'jpg', 'jpeg', 'png', 'gif', 'ods', 'odt', 'xlsx', 'doc', 'docx', 'xls', 'csv', 'txt'] allowed_ext += [e.upper() for e in allowed_ext] for e in allowed_ext: out = '%s.%s'...
def read_file(path):
if os.path.isfile(path): return open(path, "rb").read() allowed_ext = ['pdf', 'jpg', 'jpeg', 'png', 'gif', 'ods', 'odt', 'xlsx', 'doc', 'docx', 'xls', 'csv', 'txt'] allowed_ext += [e.upper() for e in allowed_ext] for e in allowed_ext: out = '%s.%s' % (path, e) ...
thing): try: f = int(thing) except ValueError: f = 0 return f def Float(thing): try: f = float(thing) except ValueError: f = 0.0 return f def read_file(path):
64
64
148
5
58
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
read_file
read_file
47
57
47
47
8a78e79efb3a79a258ff7c7f9534178ad78586cd
bigcode/the-stack
train
d268fcb41afff6fdaa3ab784
train
class
class Sample_Conditions(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_sampleconditions for row in self.get_rows(3): if row['Title']: obj = _createObjectByType("SampleCondition", folder, tmpID()) obj.edit( ...
class Sample_Conditions(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_sampleconditions for row in self.get_rows(3): if row['Title']: obj = _createObjectByType("SampleCondition", folder, tmpID()) obj.edit( title=row['Title'], descr...
Description=row['LocationDescription'], # LocationType=row['LocationType'], # ShelfTitle=row['ShelfTitle'], # ShelfCode=row['ShelfCode'], ShelfDescription=row['ShelfDescription'], ) obj.unmarkCreationFlag() renameAfterCr...
64
64
92
8
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Sample_Conditions
Sample_Conditions
1,155
1,167
1,155
1,156
ae81bb336757f9f1f059f46c3d11e2ab3e454a98
bigcode/the-stack
train
00c39171565da2e422291ba3
train
class
class Products(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if ('Category' not in row or 'Supplier' not in row): logger.info("Unable to import '%s'. Missing category or supplier...
class Products(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if ('Category' not in row or 'Supplier' not in row): logger.info("Unable to import '%s'. Missing category or supplier" % row.get('title','')) ...
.context.bika_setup.bika_productcategories for row in self.get_rows(3): obj = _createObjectByType("ProductCategory", folder, tmpID()) obj.edit( title=row['title'], description=row.get('description', ''), Prefix=row.get('...
87
87
293
6
81
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Products
Products
2,244
2,274
2,244
2,245
cb2baa9df8d8eff54052144eeb89ca92f58fe4d6
bigcode/the-stack
train
a5513b12cfd25b7c4f3c75ae
train
class
class Client_Contacts(WorksheetImporter): def Import(self): portal_groups = getToolByName(self.context, 'portal_groups') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): client = pc(portal_type="Client", getName=row['Client_...
class Client_Contacts(WorksheetImporter):
def Import(self): portal_groups = getToolByName(self.context, 'portal_groups') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): client = pc(portal_type="Client", getName=row['Client_title']) if len(client) == 0: ...
if not row['Name']: message = "Client %s has no Name" raise Exception(message) if not row['ClientID']: message = "Client %s has no Client ID" raise Exception(message) obj.edit(Name=row['Name'], ClientID=row['Cl...
162
162
541
8
154
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Client_Contacts
Client_Contacts
479
540
479
480
e92442f0904eec1fc49dd018d6819c0c9e3b1887
bigcode/the-stack
train
791ad261d74b7ae2ea3841de
train
class
class Clients(WorksheetImporter): def Import(self): folder = self.context.clients for row in self.get_rows(3): obj = _createObjectByType("Client", folder, tmpID()) if not row['Name']: message = "Client %s has no Name" raise Exception(message) ...
class Clients(WorksheetImporter):
def Import(self): folder = self.context.clients for row in self.get_rows(3): obj = _createObjectByType("Client", folder, tmpID()) if not row['Name']: message = "Client %s has no Name" raise Exception(message) if not row['ClientID']:...
'Unknown'), description=row.get('description', ''), Volume=row.get('volume', 0), Unit=str(row.get('unit', 0)), Price=str(row.get('price', 0)), ) # Rename the new object renameAfterCreation(obj) class Clients(WorksheetIm...
64
64
199
6
58
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Clients
Clients
452
476
452
453
220b5b9faf58992bd3641b98f51ec9d3abcbe1a7
bigcode/the-stack
train
13f04b417c29fd29004fcbbe
train
class
class Lab_Products(WorksheetImporter): def Import(self): context = self.context # Refer to the default folder folder = self.context.bika_setup.bika_labproducts # Iterate through the rows for row in self.get_rows(3): # Create the SRTemplate object obj ...
class Lab_Products(WorksheetImporter):
def Import(self): context = self.context # Refer to the default folder folder = self.context.bika_setup.bika_labproducts # Iterate through the rows for row in self.get_rows(3): # Create the SRTemplate object obj = _createObjectByType('LabProduct', fold...
= "Department: lookup of '%s' in LabContacts/Username failed." % row[ 'LabContact_Username'] logger.info(message) if manager: obj.setManager(manager.UID()) obj.unmarkCreationFlag() renameAfterCreation(obj) c...
64
64
158
8
56
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Lab_Products
Lab_Products
430
449
430
431
c99a4f940a02a5459ebb5914d4822c9183ad04c7
bigcode/the-stack
train
2b865e8cbeb49f795814bc11
train
class
class Stock_Items(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_stockitems bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if ('Product' not in row): logger.info("Unable to import '%s'. Missing pr...
class Stock_Items(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_stockitems bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if ('Product' not in row): logger.info("Unable to import '%s'. Missing product" % row.get('StockItemID', '')) ...
" % Float(row.get('Price', '')), Toxicity=row.get('Toxicity', ''), HealthEffects=row.get('HealthEffects', ''), StorageConditions=row.get('StorageConditions', ''), ) obj.setCategory(category) obj.unmarkCreationFlag() renameA...
69
69
231
7
62
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Stock_Items
Stock_Items
2,276
2,301
2,276
2,277
9c4565e53bbb5016727cf3b45fcf5c7ff1b3eeed
bigcode/the-stack
train
03d268df5e9eb3d7271b0b9b
train
class
class Instrument_Validations(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row.get('instrument', None) or not row.get('title', None): continue folder = self.get_object(bsc, '...
class Instrument_Validations(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row.get('instrument', None) or not row.get('title', None): continue folder = self.get_object(bsc, 'Instrument', row.get('instrument')) if...
row_dict = {'DocumentID': row.get('UserManualID', 'manual'), 'DocumentVersion': '', 'DocumentLocation': '', 'DocumentType': 'Manual', 'File': row.get('UserManualFile', None) } ...
84
84
282
9
75
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Instrument_Validations
Instrument_Validations
767
796
767
768
ad40bacb82b1680a1a799da9163cbbb9a59b4d7d
bigcode/the-stack
train
2f3cc43635f3ec199b593a07
train
class
class Instrument_Calibrations(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row.get('instrument', None) or not row.get('title', None): continue folder = self.get_object(bsc, ...
class Instrument_Calibrations(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row.get('instrument', None) or not row.get('title', None): continue folder = self.get_object(bsc, 'Instrument', row.get('instrument')) if...
, 'bika_setup_catalog') lab_contacts = [o.getObject() for o in bsc(portal_type="LabContact", inactive_state='active')] for contact in lab_contacts: if contact.getFullname() == row.get('Worker', ''): obj.setWorker(contact.UID()) ...
86
86
287
10
76
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Instrument_Calibrations
Instrument_Calibrations
799
828
799
800
5b579e01bb1a24dc14733eb45a3348d60b03562f
bigcode/the-stack
train
845c96d55e90922c7daa35bf
train
class
class Sample_Types(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_sampletypes bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("Sa...
class Sample_Types(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_sampletypes bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['title']: continue obj = _createObjectByType("SampleType", folder, tmpID()) ...
(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_batchlabels for row in self.get_rows(3): if row['title']: obj = _createObjectByType("BatchLabel", folder, tmpID()) obj.edit(title=row['title']) obj.unmarkCreation...
84
84
281
8
76
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Sample_Types
Sample_Types
1,030
1,062
1,030
1,031
4e97e66ac7e6befc6c3d8d4889ef7bfdeb6c92d9
bigcode/the-stack
train
e639e206987a2ddbcc48371e
train
class
class Analysis_Categories(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_analysiscategories bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): department = None if row.get('Department_title', None): ...
class Analysis_Categories(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_analysiscategories bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): department = None if row.get('Department_title', None): department = self.get_object(bsc, 'D...
row in self.get_rows(3): if row['Title']: obj = _createObjectByType("SampleCondition", folder, tmpID()) obj.edit( title=row['Title'], description=row.get('Description', '') ) obj.unmarkCreationFlag() ...
72
72
242
8
64
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Analysis_Categories
Analysis_Categories
1,170
1,194
1,170
1,171
d2578bdc280b9e7b336ca865da28309df0b71312
bigcode/the-stack
train
72ff2eaf4d62b80b2ccc3b37
train
class
class Sample_Points(WorksheetImporter): def Import(self): setup_folder = self.context.bika_setup.bika_samplepoints bsc = getToolByName(self.context, 'bika_setup_catalog') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): if not row['title']:...
class Sample_Points(WorksheetImporter):
def Import(self): setup_folder = self.context.bika_setup.bika_samplepoints bsc = getToolByName(self.context, 'bika_setup_catalog') pc = getToolByName(self.context, 'portal_catalog') for row in self.get_rows(3): if not row['title']: continue if ...
(row['Hazardous']), SampleMatrix=samplematrix, Prefix=row['Prefix'], MinimumVolume=row['MinimumVolume'], ContainerType=containertype ) samplepoint = self.get_object(bsc, 'SamplePoint', row.g...
94
94
315
8
86
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Sample_Points
Sample_Points
1,065
1,102
1,065
1,066
66cedd665012e723ee1cb921bce3e9d9ff9cdfda
bigcode/the-stack
train
8341688584977c2a2a387158
train
class
class Sampling_Deviations(WorksheetImporter): def Import(self): folder = self.context.bika_setup.bika_samplingdeviations for row in self.get_rows(3): if row['title']: obj = _createObjectByType("SamplingDeviation", folder, tmpID()) obj.edit( ...
class Sampling_Deviations(WorksheetImporter):
def Import(self): folder = self.context.bika_setup.bika_samplingdeviations for row in self.get_rows(3): if row['title']: obj = _createObjectByType("SamplingDeviation", folder, tmpID()) obj.edit( title=row['title'], d...
: file_data = read_file(path) obj.setMethodDocument(file_data) except Exception as msg: logger.warning(msg[0] + " Error on sheet: " + self.sheetname) obj.unmarkCreationFlag() renameAfterCreation(...
64
64
95
9
55
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Sampling_Deviations
Sampling_Deviations
1,239
1,251
1,239
1,240
4b4bf8f1df97430082b8243fd3ab789850355320
bigcode/the-stack
train
0b075b1384a7572b5b5b1a7d
train
class
class Instrument_Certifications(WorksheetImporter): def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['instrument'] or not row['title']: continue folder = self.get_object(bsc, 'Instrument', row....
class Instrument_Certifications(WorksheetImporter):
def Import(self): bsc = getToolByName(self.context, 'bika_setup_catalog') for row in self.get_rows(3): if not row['instrument'] or not row['title']: continue folder = self.get_object(bsc, 'Instrument', row.get('instrument','')) if folder: ...
('workperformed', ''), Remarks=row.get('remarks', ''), DateIssued=row.get('DateIssued', ''), ReportID=row.get('ReportID', '') ) # Gettinginstrument lab contacts bsc = getToolByName(self.context, 'bika_setup_catal...
138
138
460
9
129
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
Instrument_Certifications
Instrument_Certifications
831
879
831
832
92befe9607cfafeb5f62dee6702b7340e70c705c
bigcode/the-stack
train
2e4cad37fa4031237d8f7718
train
class
class ID_Prefixes(WorksheetImporter): def Import(self): prefixes = self.context.bika_setup.getPrefixes() for row in self.get_rows(3): # remove existing prefix from list prefixes = [p for p in prefixes if p['portal_type'] != row['portal_type']] ...
class ID_Prefixes(WorksheetImporter):
def Import(self): prefixes = self.context.bika_setup.getPrefixes() for row in self.get_rows(3): # remove existing prefix from list prefixes = [p for p in prefixes if p['portal_type'] != row['portal_type']] # The spreadsheet will contain 'no...
ARIDPadding=int(values['ARIDPadding']), ExternalIDServer=self.to_bool(values['ExternalIDServer']), IDServerURL=values['IDServerURL'], ShowNewReleasesInfo=values.get('ShowNewReleasesInfo', True), ) class ID_Prefixes(WorksheetImporter):
64
64
163
9
55
hocinebendou/bika.gsoc
bika/lims/exportimport/setupdata/__init__.py
Python
ID_Prefixes
ID_Prefixes
1,892
1,909
1,892
1,893
9273be9c7d5861b3ab45db21c10fd010edfa2bc4
bigcode/the-stack
train
c3b9e78c8d00c30c77151201
train
class
class TestTimers(greentest.TestCase): def test_timer_fired(self): lst = [1] def func(): gevent.spawn_later(0.01, lst.pop) gevent.sleep(0.02) gevent.spawn(func) assert lst == [1], lst gevent.sleep(0.03) assert lst == [], lst def test_spa...
class TestTimers(greentest.TestCase):
def test_timer_fired(self): lst = [1] def func(): gevent.spawn_later(0.01, lst.pop) gevent.sleep(0.02) gevent.spawn(func) assert lst == [1], lst gevent.sleep(0.03) assert lst == [], lst def test_spawn_is_not_cancelled(self): lst ...
_switch(0) def test_invalid_switch_1(self): self._test_wait_read_invalid_switch(0.001) # we don't test wait_write the same way, because socket is always ready to write def switch_None(g): g.switch(None) class TestTimers(greentest.TestCase):
64
64
145
9
55
Eugeny/gevent
greentest/test__api.py
Python
TestTimers
TestTimers
97
119
97
98
670e0d32cc2ecad50d9a02d7dae8aa4a3f40e40a
bigcode/the-stack
train
7bfc7ba3c7fcc90ea7e7ee4c
train
class
class Test(greentest.TestCase): def test_killing_dormant(self): state = [] def test(): try: state.append('start') gevent.sleep(DELAY) except: state.append('except') # catching GreenletExit pass ...
class Test(greentest.TestCase):
def test_killing_dormant(self): state = [] def test(): try: state.append('start') gevent.sleep(DELAY) except: state.append('except') # catching GreenletExit pass state.append('finishe...
all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE L...
141
141
473
8
132
Eugeny/gevent
greentest/test__api.py
Python
Test
Test
29
88
29
30
efb4ac5a90820c344c819aa90220a02dcb14549d
bigcode/the-stack
train
f063eef6f1cd0f579507bdf0
train
function
def switch_None(g): g.switch(None)
def switch_None(g):
g.switch(None)
test_invalid_switch_0(self): self._test_wait_read_invalid_switch(0) def test_invalid_switch_1(self): self._test_wait_read_invalid_switch(0.001) # we don't test wait_write the same way, because socket is always ready to write def switch_None(g):
64
64
10
5
58
Eugeny/gevent
greentest/test__api.py
Python
switch_None
switch_None
93
94
93
93
b7a7d4aacbace1fbab3c385a7ecb62bfcfd0d691
bigcode/the-stack
train
0b42b2cdca8ef10987f07726
train
function
def hashint(num): if num == 0: return '0' if num < 0: sign = '-' num = -num else: sign = '' result = '' while num: result = CHARSET[num % (BASE)] + result num //= BASE return sign + result
def hashint(num):
if num == 0: return '0' if num < 0: sign = '-' num = -num else: sign = '' result = '' while num: result = CHARSET[num % (BASE)] + result num //= BASE return sign + result
from datetime import datetime from uuid import uuid1 as uuid from platform import python_version # hash any int to about a b64ish CHARSET = '0123456789abcdefghjklmnopqrstvwxyzABCDEFGHJKLMNOPQRSTVWXYZ' BASE = len(CHARSET) def hashint(num):
64
64
74
5
59
nod/databag
src/databag/main.py
Python
hashint
hashint
13
24
13
13
6d4ae19d89ec7fae7ea070ec16101938d0d792dc
bigcode/the-stack
train
aeca1027aff1970e607c4ebc
train
class
class Qmeta(type): """ allows us some syntactic sugar for attr access """ def __getattr__(cls, key): return Q(key)
class Qmeta(type):
""" allows us some syntactic sugar for attr access """ def __getattr__(cls, key): return Q(key)
def __contains__(self, keyf): cur = self._db.cursor() cur.execute( '''select 1 from {tbl} where keyf=?'''.format(tbl=self._table), (keyf,) ) return cur.fetchone() is not None class Qmeta(type):
64
64
32
5
58
nod/databag
src/databag/main.py
Python
Qmeta
Qmeta
221
224
221
221
7c56952825406204afdcab72bd9c623c4e7209d6
bigcode/the-stack
train
660795bf4d0df69ea9db489b
train
class
class DataBag(object): """ put your data in a bag. ```python bag = DataBag('dbag', '/tmp/bag.sqlite3') bag['blah'] = 'blip' ``` """ def __init__(self, table=None, fpath=None, versioned=False, history=10): if not fpath: fpath=':memory:' self._table = table ...
class DataBag(object):
""" put your data in a bag. ```python bag = DataBag('dbag', '/tmp/bag.sqlite3') bag['blah'] = 'blip' ``` """ def __init__(self, table=None, fpath=None, versioned=False, history=10): if not fpath: fpath=':memory:' self._table = table self._versioned =...
import json import operator import sqlite3 from bz2 import compress, decompress from datetime import datetime from uuid import uuid1 as uuid from platform import python_version # hash any int to about a b64ish CHARSET = '0123456789abcdefghjklmnopqrstvwxyzABCDEFGHJKLMNOPQRSTVWXYZ' BASE = len(CHARSET) def hashint(num):...
156
256
1,432
5
150
nod/databag
src/databag/main.py
Python
DataBag
DataBag
27
218
27
27
2c8413cfb632ec6667af5c5045a1e2cc93c1c189
bigcode/the-stack
train
59ea067b4989fef0bd17b542
train
class
class Q(metaclass=Qmeta): """ builds queries for dictbag instances using find() NOTE - if there aren't indexes on the searched fields, this is SLOW ```python d = DictBag('dbag') d.add({'x':23})) for i in d.find(Q('x')>20, Q('x')<30): ... ``` NOTE: multiple Q's on the sam...
class Q(metaclass=Qmeta):
""" builds queries for dictbag instances using find() NOTE - if there aren't indexes on the searched fields, this is SLOW ```python d = DictBag('dbag') d.add({'x':23})) for i in d.find(Q('x')>20, Q('x')<30): ... ``` NOTE: multiple Q's on the same key get and'd. OR isn't ...
desc else 'asc' cur.execute( '''select keyf, data, json, bz2 from {tbl} order by ts {o}'''.format( tbl=self._table, o=order ) ) for d in cur: yield d['keyf'], self._data(d) def __contains__(self, keyf): ...
169
169
564
9
160
nod/databag
src/databag/main.py
Python
Q
Q
227
311
227
228
706ab07e3f4796bec6a999efdb1473445de9080d
bigcode/the-stack
train
2cca842c244b3c14c55db5d7
train
class
class DictBag(DataBag): """ convenience bag for dictionaries that adds an index field. This allows ranged retrievals based on queries on indexed fields. NOTE - the entire index model here is heavily inspired by goatfish """ def __init__(self, table=None, fpath=None, indexes=None): s...
class DictBag(DataBag):
""" convenience bag for dictionaries that adds an index field. This allows ranged retrievals based on queries on indexed fields. NOTE - the entire index model here is heavily inspired by goatfish """ def __init__(self, table=None, fpath=None, indexes=None): super(DictBag, self).__in...
(self): return self._k # we have to use a list instead of a set on the _ands because in order to # test the generated sql, we need to be able to predict the order of the # params output and a set() lacks that attribute def _cond(self, sym, val): """ builds the anded sets of sql syntax ...
256
256
2,229
6
250
nod/databag
src/databag/main.py
Python
DictBag
DictBag
314
597
314
314
2e1f647812a5493c031009de4f23398d5ef5fdae
bigcode/the-stack
train
49aa07dec13b455a603bd81f
train
class
class OnDemandKoreaIE(JWPlatformBaseIE): _VALID_URL = r'https?://(?:www\.)?ondemandkorea\.com/(?P<id>[^/]+)\.html' _TEST = { 'url': 'http://www.ondemandkorea.com/ask-us-anything-e43.html', 'info_dict': { 'id': 'ask-us-anything-e43', 'ext': 'mp4', 'title': 'Ask...
class OnDemandKoreaIE(JWPlatformBaseIE):
_VALID_URL = r'https?://(?:www\.)?ondemandkorea\.com/(?P<id>[^/]+)\.html' _TEST = { 'url': 'http://www.ondemandkorea.com/ask-us-anything-e43.html', 'info_dict': { 'id': 'ask-us-anything-e43', 'ext': 'mp4', 'title': 'Ask Us Anything : E43', 'thumbna...
# coding: utf-8 from __future__ import unicode_literals from .jwplatform import JWPlatformBaseIE from ..utils import ( ExtractorError, js_to_json, ) class OnDemandKoreaIE(JWPlatformBaseIE):
53
133
444
12
41
chendaiming/youtube-dl
youtube_dl/extractor/ondemandkorea.py
Python
OnDemandKoreaIE
OnDemandKoreaIE
11
60
11
11
147c83849dba4bdfbcc623bf55ab18bb85d6d7ae
bigcode/the-stack
train
4064b8069a556f359fb582b6
train
function
def stop(args): if (f"{args.platform}" == "GKE"): """ Shutdown the GKE Cluster with the demo environment deployed. """ print_color(f"Stopping GKE cluster in project {args.project} with name {args.name} in zone {args.zone}", bcolors.OKBLUE) # Set GCloud project run_sh...
def stop(args):
if (f"{args.platform}" == "GKE"): """ Shutdown the GKE Cluster with the demo environment deployed. """ print_color(f"Stopping GKE cluster in project {args.project} with name {args.name} in zone {args.zone}", bcolors.OKBLUE) # Set GCloud project run_shell(f"gcloud con...
", bcolors.WARNING) print_color("*", bcolors.WARNING) print_color("* IMPORTANT: To reliably detect Chaos experiment incidents you must reduce the Refractory Period for your account to 10 minutes.", bcolors.WARNING) print_color("*", bcolors.WARNING) print_color("**************************...
73
73
245
4
69
jabhishek87/litmus-demo
manage.py
Python
stop
stop
232
258
232
232
a8407f24fde703054e9be317d5836c604f721cf9
bigcode/the-stack
train
187fb35144543df6b5070ec2
train
function
def run_experiment(experiment: str): """ Run a specific experiment :param experiment: The name of the experiment as defined in the YAML, i.e. container-kill :return: ExperimentResult object with results of experiment """ print_color("*************************************************...
def run_experiment(experiment: str):
""" Run a specific experiment :param experiment: The name of the experiment as defined in the YAML, i.e. container-kill :return: ExperimentResult object with results of experiment """ print_color("**************************************************************************************...
""" print_color(f"Stopping kind cluster", bcolors.OKBLUE) run_shell(f"kind delete cluster") elif (f"{args.platform}" == "EKS"): """ Shutdown the EKS Cluster with the demo environment deployed. """ print_color(f"Stopping EKS cluster with name {args.name} in {a...
168
168
563
9
158
jabhishek87/litmus-demo
manage.py
Python
run_experiment
run_experiment
270
317
270
270
b09befad4a81669098d4776210462e65d9611ec5
bigcode/the-stack
train
071a312625ed9a445d6b5fbf
train
function
def test(args): """ Run Litmus ChaosEngine Experiments inside the demo environment. Each experiment is defined under its own yaml file under the /litmus directory. You can run a specific experiment by specifying a test name that matches one of the yaml file names in the directory but by default all ...
def test(args):
""" Run Litmus ChaosEngine Experiments inside the demo environment. Each experiment is defined under its own yaml file under the /litmus directory. You can run a specific experiment by specifying a test name that matches one of the yaml file names in the directory but by default all '*' experiments ...
.experiments[0].status}' -n " + namespace run_shell(expStatusCmd) logs_cmd = f"kubectl logs --since=10s -l name={experiment} -n {namespace}" print(f"\n{bcolors.OKGREEN}//** Experiment Logs ({logs_cmd}) **//\n\n") try: while subprocess.check_output(expStatusCmd, shell=True).decode('unicode-escape...
256
256
1,703
4
252
jabhishek87/litmus-demo
manage.py
Python
test
test
319
472
319
319
3b43b0a2a70e7c808a8c188f7eb86e29c18c6c5b
bigcode/the-stack
train
8f9549a53a87edffad406e78
train
function
def start(args): if (f"{args.platform}" == "GKE"): """ Start a GKE Cluster with the demo environment deployed. """ print_color(f"Starting GKE cluster in project {args.project} with name {args.name} in zone {args.zone}", bcolors.OKBLUE) # Ensure GCloud SDK is up to date ...
def start(args):
if (f"{args.platform}" == "GKE"): """ Start a GKE Cluster with the demo environment deployed. """ print_color(f"Starting GKE cluster in project {args.project} with name {args.name} in zone {args.zone}", bcolors.OKBLUE) # Ensure GCloud SDK is up to date run_shell("gcl...
import SimpleDocTemplate, Paragraph, Table, TableStyle, Image from reportlab.lib.styles import getSampleStyleSheet class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' ...
256
256
2,723
4
251
jabhishek87/litmus-demo
manage.py
Python
start
start
48
230
48
48
6f4e73916aae02d46eee8d08dccf20cc58fd2f08
bigcode/the-stack
train
5fe7de93735c13ca208aa9a7
train
class
class ExperimentResult(object): """ Holds Experiment Result """ def __init__(self, name:str, status:str, startTime:datetime): self.name = name self.status = status self.startTime = startTime
class ExperimentResult(object):
""" Holds Experiment Result """ def __init__(self, name:str, status:str, startTime:datetime): self.name = name self.status = status self.startTime = startTime
demo environment deployed. """ print_color(f"Stopping EKS cluster with name {args.name} in {args.awsregion}", bcolors.OKBLUE) # Stop cluster run_shell(f"eksctl delete cluster --name={args.name} --region={args.awsregion}") class ExperimentResult(object):
64
64
52
5
59
jabhishek87/litmus-demo
manage.py
Python
ExperimentResult
ExperimentResult
260
268
260
260
8471551cd8cd0bee1d7415f7b621e3db870ecdd8
bigcode/the-stack
train
011de2d1ac65c3f0ec942b25
train
class
class bcolors: HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m'
class bcolors:
HEADER = '\033[95m' OKBLUE = '\033[94m' OKGREEN = '\033[92m' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m'
from datetime import datetime import subprocess import yaml from reportlab.lib import colors from reportlab.lib.pagesizes import LETTER from reportlab.platypus import SimpleDocTemplate, Paragraph, Table, TableStyle, Image from reportlab.lib.styles import getSampleStyleSheet class bcolors:
64
64
81
4
59
jabhishek87/litmus-demo
manage.py
Python
bcolors
bcolors
16
24
16
16
5f7e03f4c4ce6d6755a3f0d7757a09dddb8dab2f
bigcode/the-stack
train
d034efbe0e0fdde2ef01e40c
train
function
def run_shell(cmd: str): """ Runs a shell command and prints command to stdout before running so user can see what was run :param cmd: The shell command to run :return: """ print_color(f"** RUNNING: {cmd}") os.system(cmd)
def run_shell(cmd: str):
""" Runs a shell command and prints command to stdout before running so user can see what was run :param cmd: The shell command to run :return: """ print_color(f"** RUNNING: {cmd}") os.system(cmd)
Utility method to print colored text to stdout. :param text: The text to print :param color: The bcolors to print text in (defaults to bold) :return: """ print(f"{color}{text}{bcolors.ENDC}") def run_shell(cmd: str):
64
64
66
7
57
jabhishek87/litmus-demo
manage.py
Python
run_shell
run_shell
36
45
36
36
f3bccef2e81f1fe5f24be547418e4bdbda132554
bigcode/the-stack
train
471f138b575b1827ecc05b46
train
function
def print_color(text: str, color:bcolors = bcolors.BOLD): """ Utility method to print colored text to stdout. :param text: The text to print :param color: The bcolors to print text in (defaults to bold) :return: """ print(f"{color}{text}{bcolors.ENDC}")
def print_color(text: str, color:bcolors = bcolors.BOLD):
""" Utility method to print colored text to stdout. :param text: The text to print :param color: The bcolors to print text in (defaults to bold) :return: """ print(f"{color}{text}{bcolors.ENDC}")
' WARNING = '\033[93m' FAIL = '\033[91m' ENDC = '\033[0m' BOLD = '\033[1m' UNDERLINE = '\033[4m' def print_color(text: str, color:bcolors = bcolors.BOLD):
64
64
75
15
49
jabhishek87/litmus-demo
manage.py
Python
print_color
print_color
26
34
26
26
e706a68b098eb63e7c68605a4d9500ae7c369709
bigcode/the-stack
train
31db5b7f49c28f890e35936c
train
function
def list(args): """ List all available Litmus Chaos Experiments available in this repository """ experiments = sorted(os.listdir('./litmus')) print_color("Available Litmus Chaos Experiments:\n\n") if (f"{args.platform}" == "GKE"): i = 1 for experiment_file in experiments: ...
def list(args):
""" List all available Litmus Chaos Experiments available in this repository """ experiments = sorted(os.listdir('./litmus')) print_color("Available Litmus Chaos Experiments:\n\n") if (f"{args.platform}" == "GKE"): i = 1 for experiment_file in experiments: print_color...
para2) para3 = Paragraph("The total experiment execution time: %s (HH:MM:SS)" % str(totalTime), styles['Heading3']) elems.append(para3) pdf.build(elems) print_color("PDF Report Created Successfully ", bcolors.OKBLUE) def list(args):
65
65
219
4
61
jabhishek87/litmus-demo
manage.py
Python
list
list
475
498
475
475
b722206071884d391ae49babb2f19d18d087cdca
bigcode/the-stack
train
074426bab42396e4d1c651b5
train
function
def disconnected(client): # Disconnected function will be called when the client disconnects. print("Disconnected from Adafruit IO!")
def disconnected(client): # Disconnected function will be called when the client disconnects.
print("Disconnected from Adafruit IO!")
client so you can make # calls against it easily. print("Connected to Adafruit IO!") # Subscribe to a feed named location io.subscribe("location") # pylint: disable=unused-argument def disconnected(client): # Disconnected function will be called when the client disconnects.
64
64
27
18
45
makermelissa/Adafruit_CircuitPython_AdafruitIO
examples/adafruit_io_mqtt/adafruit_io_location.py
Python
disconnected
disconnected
66
68
66
67
a07d3bdd9be13f2d7c81c0916cc4d9f4841f8424
bigcode/the-stack
train
a3f5678a0f8c315e121c4b7b
train
function
def connected(client): # Connected function will be called when the client is connected to Adafruit IO. # This is a good place to subscribe to feed changes. The client parameter # passed to this function is the Adafruit IO MQTT client so you can make # calls against it easily. print("Connected to A...
def connected(client): # Connected function will be called when the client is connected to Adafruit IO. # This is a good place to subscribe to feed changes. The client parameter # passed to this function is the Adafruit IO MQTT client so you can make # calls against it easily.
print("Connected to Adafruit IO!") # Subscribe to a feed named location io.subscribe("location")
def connected(client): # Connected function will be called when the client is connected to Adafruit IO. # This is a good place to subscribe to feed changes. The client parameter # passed to this function is the Adafruit IO MQTT client so you can make # calls against it easily.
64
64
88
64
0
makermelissa/Adafruit_CircuitPython_AdafruitIO
examples/adafruit_io_mqtt/adafruit_io_location.py
Python
connected
connected
54
62
54
58
14303781e29d574114eab54cd60dbce4ae49a154
bigcode/the-stack
train
1a8a12ef7deb5db56e8f87f5
train
function
def message(client, feed_id, payload): # Message function will be called when a subscribed feed has a new value. # The feed_id parameter identifies the feed, and the payload parameter has # the new value. print("Feed {0} received new value: {1}".format(feed_id, payload))
def message(client, feed_id, payload): # Message function will be called when a subscribed feed has a new value. # The feed_id parameter identifies the feed, and the payload parameter has # the new value.
print("Feed {0} received new value: {1}".format(feed_id, payload))
("Disconnected from Adafruit IO!") # pylint: disable=unused-argument def message(client, feed_id, payload): # Message function will be called when a subscribed feed has a new value. # The feed_id parameter identifies the feed, and the payload parameter has # the new value.
64
64
67
47
16
makermelissa/Adafruit_CircuitPython_AdafruitIO
examples/adafruit_io_mqtt/adafruit_io_location.py
Python
message
message
72
76
72
75
b920c95daedc6726d2603c38f84ec37695e57fc6
bigcode/the-stack
train
608bbb9c30498139b6635edd
train
class
class filter_directory_files_extension: def __init__(self, directory='path', extension='.nii .json'): import os self.outfiles = [] for filePath in os.listdir(directory): if filePath.endswith(tuple(extension.split(' '))): self.outfiles.append(filePath) def ou...
class filter_directory_files_extension:
def __init__(self, directory='path', extension='.nii .json'): import os self.outfiles = [] for filePath in os.listdir(directory): if filePath.endswith(tuple(extension.split(' '))): self.outfiles.append(filePath) def output_filtered_files(self: 'list_path'): ...
nii .json'): self.outfiles = [] for filePath in input_files: if filePath.endswith(tuple(extension.split(' '))): self.outfiles.append(filePath) def output_filtered_files(self: 'list_path'): return self.outfiles ####################################################...
63
64
79
6
57
montigno/mri_works
mri_works/NodeEditor/modules/File_IO/File_filter.py
Python
filter_directory_files_extension
filter_directory_files_extension
93
103
93
94
eb745c9e72f67b962362c26613f8f0f39495c28b
bigcode/the-stack
train
644977f52946c5571e6d3663
train
class
class filter_input_files_pattern: def __init__(self, input_files=['path'], operator='enumerate(("==",\ "!=","contains",\ "not contains",\ "in",\ ...
class filter_input_files_pattern:
def __init__(self, input_files=['path'], operator='enumerate(("==",\ "!=","contains",\ "not contains",\ "in",\ "not in"))', ...
pattern.strip(): self.outfiles.append(os.path.join(directory, file)) elif operator == 'not in': if file not in pattern.strip(): self.outfiles.append(os.path.join(directory, file)) def output_filtered_files(self: 'list_path'): return self....
68
69
232
6
62
montigno/mri_works
mri_works/NodeEditor/modules/File_IO/File_filter.py
Python
filter_input_files_pattern
filter_input_files_pattern
40
74
40
41
b189084a09b8f609f54ac1da9d4d9f9542daa350
bigcode/the-stack
train
e78436fafd7148b2eab6ad5e
train
class
class filter_files_extension: def __init__(self, input_files=['path'], extension='.nii .json'): self.outfiles = [] for filePath in input_files: if filePath.endswith(tuple(extension.split(' '))): self.outfiles.append(filePath) def output_filtered_files(self: 'list_pa...
class filter_files_extension:
def __init__(self, input_files=['path'], extension='.nii .json'): self.outfiles = [] for filePath in input_files: if filePath.endswith(tuple(extension.split(' '))): self.outfiles.append(filePath) def output_filtered_files(self: 'list_path'): return self.outfi...
if file in pattern.strip(): self.outfiles.append(filePath) elif operator == 'not in': if file not in pattern.strip(): self.outfiles.append(filePath) def output_filtered_files(self: 'list_path'): return self.outfiles ######...
63
64
74
5
58
montigno/mri_works
mri_works/NodeEditor/modules/File_IO/File_filter.py
Python
filter_files_extension
filter_files_extension
79
88
79
80
22dba623eb669b4c33f19f95f6f18b8c43b987b5
bigcode/the-stack
train
cc7e1a778871a9c9441e0968
train
class
class filter_directory_files_pattern: def __init__(self, directory='path', operator='enumerate(("==",\ "!=",\ "contains",\ "not contains",\ ...
class filter_directory_files_pattern:
def __init__(self, directory='path', operator='enumerate(("==",\ "!=",\ "contains",\ "not contains",\ "in",\ ...
class filter_directory_files_pattern:
6
74
248
6
0
montigno/mri_works
mri_works/NodeEditor/modules/File_IO/File_filter.py
Python
filter_directory_files_pattern
filter_directory_files_pattern
1
35
1
2
982c9e5b947488081ba6b98ec63fe4efc579f4c8
bigcode/the-stack
train
2b5f026dc1ac715b94e4994f
train
class
class GroupsRequest(Request): def get_method(self) -> str: return "groups.get"
class GroupsRequest(Request):
def get_method(self) -> str: return "groups.get"
from suvec.common.requesting import Request class FriendsRequest(Request): def get_method(self) -> str: return "friends.get" class GroupsRequest(Request):
34
64
20
5
29
ProtsenkoAI/skady-user-vectorizer
suvec/vk_api_impl/requesting/requests.py
Python
GroupsRequest
GroupsRequest
9
11
9
9
9d3d678371547c647e120a3bf2e0b7d79703eebb
bigcode/the-stack
train
d63d5b0c7ac9bed01466f287
train
class
class FriendsRequest(Request): def get_method(self) -> str: return "friends.get"
class FriendsRequest(Request):
def get_method(self) -> str: return "friends.get"
from suvec.common.requesting import Request class FriendsRequest(Request):
14
64
20
5
8
ProtsenkoAI/skady-user-vectorizer
suvec/vk_api_impl/requesting/requests.py
Python
FriendsRequest
FriendsRequest
4
6
4
4
0aa6768f831c09f422efd299df94cb2b6c765b7b
bigcode/the-stack
train
cb7fd803567d43d2ecc26cb7
train
class
class CartItem(models.Model): cart = DeferredForeignKey('cart', related_name='items', editable=False) variant = DeferredForeignKey('variant', related_name='+', editable=False) quantity = models.DecimalField(_("quantity"), max_digits=10, decimal_places=4) class Meta: ...
class CartItem(models.Model):
cart = DeferredForeignKey('cart', related_name='items', editable=False) variant = DeferredForeignKey('variant', related_name='+', editable=False) quantity = models.DecimalField(_("quantity"), max_digits=10, decimal_places=4) class Meta: abstract = True ...
, reason) def get_quantity(self, variant, **kwargs): try: return self.get_item(variant=variant, **kwargs).quantity except ObjectDoesNotExist: return Decimal('0') def is_empty(self): return not self.items.exists() class CartItem(models.Model):
64
64
139
6
58
atkinson/satchless
satchless/cart/models.py
Python
CartItem
CartItem
138
154
138
139
aa5b6796f8ea9de72f642dfea52369c59b6bba08
bigcode/the-stack
train
38f31602d6eb9a6cba6a5f68
train
function
def get_default_currency(): return settings.SATCHLESS_DEFAULT_CURRENCY
def get_default_currency():
return settings.SATCHLESS_DEFAULT_CURRENCY
Decimal from django.conf import settings from django.db import models from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ from django.core.exceptions import ObjectDoesNotExist import random from ..util.models import DeferredForeignKey from . import signals def get_defau...
64
64
15
5
58
atkinson/satchless
satchless/cart/models.py
Python
get_default_currency
get_default_currency
13
14
13
13
ff2df4e6b49e219d4f13b6c4c39f228ce99515bb
bigcode/the-stack
train
bacb95ef01bb8e29a5db447f
train
class
class Cart(models.Model): owner = models.ForeignKey(User, null=True, blank=True, related_name='+') typ = models.CharField(_("type"), max_length=100) currency = models.CharField(_("currency"), max_length=3, default=get_default_currency) token = models.CharField(max_length...
class Cart(models.Model):
owner = models.ForeignKey(User, null=True, blank=True, related_name='+') typ = models.CharField(_("type"), max_length=100) currency = models.CharField(_("currency"), max_length=3, default=get_default_currency) token = models.CharField(max_length=32, blank=True, default=''...
# -*- coding: utf-8 -*- from decimal import Decimal from django.conf import settings from django.db import models from django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ from django.core.exceptions import ObjectDoesNotExist import random from ..util.models import DeferredFor...
145
234
783
5
139
atkinson/satchless
satchless/cart/models.py
Python
Cart
Cart
25
135
25
26
b20165ac5162da89539f436f01db8af59d29d004
bigcode/the-stack
train
adbda30442a527d5716c2814
train
class
class QuantityResult(object): def __init__(self, cart_item, new_quantity, quantity_delta, reason=None): self.cart_item = cart_item self.new_quantity = new_quantity self.quantity_delta = quantity_delta self.reason = reason
class QuantityResult(object):
def __init__(self, cart_item, new_quantity, quantity_delta, reason=None): self.cart_item = cart_item self.new_quantity = new_quantity self.quantity_delta = quantity_delta self.reason = reason
django.contrib.auth.models import User from django.utils.translation import ugettext_lazy as _ from django.core.exceptions import ObjectDoesNotExist import random from ..util.models import DeferredForeignKey from . import signals def get_default_currency(): return settings.SATCHLESS_DEFAULT_CURRENCY class Quanti...
64
64
55
5
58
atkinson/satchless
satchless/cart/models.py
Python
QuantityResult
QuantityResult
16
22
16
17
e97f3558e27dd28d020ed17db0d8273010e6ce26
bigcode/the-stack
train
fe0aabfbf916fd58ce994abd
train
function
def translate(x, y, z): return np.array( [[1, 0, 0, x], [0, 1, 0, y], [0, 0, 1, z], [0, 0, 0, 1]], dtype=float )
def translate(x, y, z):
return np.array( [[1, 0, 0, x], [0, 1, 0, y], [0, 0, 1, z], [0, 0, 0, 1]], dtype=float )
aspect, znear, zfar): h = np.tan(0.5 * np.radians(fovy)) * znear w = h * aspect return frustum(-w, w, -h, h, znear, zfar) def translate(x, y, z):
64
64
64
8
56
rossbar/blog.scientific-python.org
content/posts/matplotlib/custom-3d-engine/bunny-8.py
Python
translate
translate
24
27
24
24
b7b3c163ed10917f076c82ac288a4acd3286f430
bigcode/the-stack
train
40738a495ffe33212618397d
train
function
def yrotate(theta): t = np.pi * theta / 180 c, s = np.cos(t), np.sin(t) return np.array( [[c, 0, s, 0], [0, 1, 0, 0], [-s, 0, c, 0], [0, 0, 0, 1]], dtype=float )
def yrotate(theta):
t = np.pi * theta / 180 c, s = np.cos(t), np.sin(t) return np.array( [[c, 0, s, 0], [0, 1, 0, 0], [-s, 0, c, 0], [0, 0, 0, 1]], dtype=float )
.sin(t) return np.array( [[1, 0, 0, 0], [0, c, -s, 0], [0, s, c, 0], [0, 0, 0, 1]], dtype=float ) def yrotate(theta):
64
64
86
5
59
rossbar/blog.scientific-python.org
content/posts/matplotlib/custom-3d-engine/bunny-8.py
Python
yrotate
yrotate
38
43
38
38
b41d6833879126f61a3caa06faddfa050d86ccee
bigcode/the-stack
train
25a88f82c55fdfd95335ec19
train
function
def xrotate(theta): t = np.pi * theta / 180 c, s = np.cos(t), np.sin(t) return np.array( [[1, 0, 0, 0], [0, c, -s, 0], [0, s, c, 0], [0, 0, 0, 1]], dtype=float )
def xrotate(theta):
t = np.pi * theta / 180 c, s = np.cos(t), np.sin(t) return np.array( [[1, 0, 0, 0], [0, c, -s, 0], [0, s, c, 0], [0, 0, 0, 1]], dtype=float )
, z): return np.array( [[1, 0, 0, x], [0, 1, 0, y], [0, 0, 1, z], [0, 0, 0, 1]], dtype=float ) def xrotate(theta):
64
64
85
5
59
rossbar/blog.scientific-python.org
content/posts/matplotlib/custom-3d-engine/bunny-8.py
Python
xrotate
xrotate
30
35
30
30
127ea19eb7353670518b233e61f33287aa292aed
bigcode/the-stack
train
ef79901dd973b697f465030a
train
function
def perspective(fovy, aspect, znear, zfar): h = np.tan(0.5 * np.radians(fovy)) * znear w = h * aspect return frustum(-w, w, -h, h, znear, zfar)
def perspective(fovy, aspect, znear, zfar):
h = np.tan(0.5 * np.radians(fovy)) * znear w = h * aspect return frustum(-w, w, -h, h, znear, zfar)
/ (top - bottom) M[2, 3] = -2.0 * znear * zfar / (zfar - znear) M[3, 2] = -1.0 return M def perspective(fovy, aspect, znear, zfar):
64
64
61
13
50
rossbar/blog.scientific-python.org
content/posts/matplotlib/custom-3d-engine/bunny-8.py
Python
perspective
perspective
18
21
18
18
4b0a981220d239bcca9a40fc0358010585f7a70a
bigcode/the-stack
train
34e1f7e5e95a7dcb1095c0b7
train
function
def frustum(left, right, bottom, top, znear, zfar): M = np.zeros((4, 4), dtype=np.float32) M[0, 0] = +2.0 * znear / (right - left) M[1, 1] = +2.0 * znear / (top - bottom) M[2, 2] = -(zfar + znear) / (zfar - znear) M[0, 2] = (right + left) / (right - left) M[2, 1] = (top + bottom) / (top - bottom...
def frustum(left, right, bottom, top, znear, zfar):
M = np.zeros((4, 4), dtype=np.float32) M[0, 0] = +2.0 * znear / (right - left) M[1, 1] = +2.0 * znear / (top - bottom) M[2, 2] = -(zfar + znear) / (zfar - znear) M[0, 2] = (right + left) / (right - left) M[2, 1] = (top + bottom) / (top - bottom) M[2, 3] = -2.0 * znear * zfar / (zfar - znear)...
import numpy as np import matplotlib.pyplot as plt from matplotlib.collections import PolyCollection def frustum(left, right, bottom, top, znear, zfar):
35
64
186
17
17
rossbar/blog.scientific-python.org
content/posts/matplotlib/custom-3d-engine/bunny-8.py
Python
frustum
frustum
6
15
6
6
42a4548b3bd99b4c5d16387a6343781f348f405d
bigcode/the-stack
train
31585511a3e991185c008a17
train
function
def main(): # TODO: argument valdiation args = parse_args() input_file = args.i freq_file = args.f if args.o == 'kaldi_ops_by_corpus_freq': out_dir = args.o + '_' + time.strftime("%Y%m%d-%H%M%S") + '/' else: out_dir = args.o if not out_dir.endswith('/'): out...
def main(): # TODO: argument valdiation
args = parse_args() input_file = args.i freq_file = args.f if args.o == 'kaldi_ops_by_corpus_freq': out_dir = args.o + '_' + time.strftime("%Y%m%d-%H%M%S") + '/' else: out_dir = args.o if not out_dir.endswith('/'): out_dir += '/' # allow to overwrite existin...
.add_argument('-o', type=str, default='kaldi_ops_by_corpus_freq', help='Output directory') parser.add_argument('-n', type=int, help='Number of most frequent words to include in accuracy analysis') return parser.parse_args() def main(): # TODO: argument valdiation
64
64
187
12
52
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
main
main
180
208
180
182
8ab78a3c5cebedd056cbe110bd55a64411fc6a4a
bigcode/the-stack
train
28f934ebea5a2978f3b91122
train
function
def accumulate_statistics(stat_list): # Accumulates statistics from 'stat_list' based on word frequency count_map = {} for op_stat in stat_list: if op_stat.word == '***': continue word_freq = op_stat.corpus_frequency acc_word = count_map[word_freq] if word_freq in count_...
def accumulate_statistics(stat_list): # Accumulates statistics from 'stat_list' based on word frequency
count_map = {} for op_stat in stat_list: if op_stat.word == '***': continue word_freq = op_stat.corpus_frequency acc_word = count_map[word_freq] if word_freq in count_map else operationstats.OperationStatistics(str(word_freq)) acc_word.increment_all(op_stat) ...
str(ref_freq) + ') replaced by ' + hyp + ' (' + str(hyp_freq) + ') ' + str( count) + ' times') self.counter_gt_with_lt += count def accumulate_statistics(stat_list): # Accumulates statistics from 'stat_list' based on word frequency
64
64
106
22
41
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
accumulate_statistics
accumulate_statistics
68
80
68
69
dc0114e2b55a6f376da539d2935e6939b8348d8c
bigcode/the-stack
train
a88ffdcf655dfb580b715ca6
train
function
def write_results(result_maps, out_dir, top_freq): references_list = list(result_maps.reference_map.values()) references_list.sort(key=lambda x: x.correct, reverse=True) hypothesis_list = list(result_maps.hypothesis_map.values()) hypothesis_list.sort(key=lambda x: x.correct, reverse=True) # write...
def write_results(result_maps, out_dir, top_freq):
references_list = list(result_maps.reference_map.values()) references_list.sort(key=lambda x: x.correct, reverse=True) hypothesis_list = list(result_maps.hypothesis_map.values()) hypothesis_list.sort(key=lambda x: x.correct, reverse=True) # write by correct? references_list.sort(key=lambda x:...
items_as_arrays.append(item.print_array(True)) widths = [max(map(len, col)) for col in zip(*items_as_arrays)] for row in items_as_arrays: out_file.write(" ".join((val.ljust(width) for val, width in zip(row, widths))) + '\n') out_file.close() def write_file(filename, list_to_write): with o...
159
159
530
12
146
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
write_results
write_results
112
150
112
113
706d0fa513e3d52b1f09ce15355ead8d72171f78
bigcode/the-stack
train
eb94372ccb18963b64fbf5ff
train
class
class WordMaps: # Holds operation information on reference words and hypothesis words separately def __init__(self): self.reference_map = {} self.hypothesis_map = {} self.subst_lt_with_gt = [] # substitutions of more freq with less freq or longer with shorter self.subst_gt_with_...
class WordMaps: # Holds operation information on reference words and hypothesis words separately
def __init__(self): self.reference_map = {} self.hypothesis_map = {} self.subst_lt_with_gt = [] # substitutions of more freq with less freq or longer with shorter self.subst_gt_with_lt = [] # substitutions of less freq with more freq or shorter with longer self.counter_lt_wit...
usr/bin/env python3 # -*- coding: utf-8 -*- """ Are less frequent words more likely to cause errors than more frequent ones? Are less frequent words replaced with more frequent words? Input format ops file (not tabs, only spaces for formatting): description(corr, ins, del, sub) reference hypothesis count ...
123
123
410
17
105
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
WordMaps
WordMaps
28
65
28
30
4d5ef1ff7a9d4bbe292e532de2c85f0bcde44b41
bigcode/the-stack
train
b30d14222bfc326bb6e0970a
train
function
def write_file(filename, list_to_write): with open(filename, 'w') as f: for line in list_to_write: f.write(line + '\n')
def write_file(filename, list_to_write):
with open(filename, 'w') as f: for line in list_to_write: f.write(line + '\n')
(map(len, col)) for col in zip(*items_as_arrays)] for row in items_as_arrays: out_file.write(" ".join((val.ljust(width) for val, width in zip(row, widths))) + '\n') out_file.close() def write_file(filename, list_to_write):
64
64
36
9
55
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
write_file
write_file
98
101
98
98
5fd048b226aed6d4e494c408d4b0abffaf3b1e9b
bigcode/the-stack
train
fbbfd1ad711ddd02970652b2
train
function
def write_array_list_to_file(filename, list_to_write): out_file = open(filename, 'w') header = ['WORD', 'OCC', 'C', 'D', 'I', 'S', '%Correct', 'FREQ'] items_as_arrays = [header] for item in list_to_write: items_as_arrays.append(item.print_array(True)) widths = [max(map(len, col)) for col in...
def write_array_list_to_file(filename, list_to_write):
out_file = open(filename, 'w') header = ['WORD', 'OCC', 'C', 'D', 'I', 'S', '%Correct', 'FREQ'] items_as_arrays = [header] for item in list_to_write: items_as_arrays.append(item.print_array(True)) widths = [max(map(len, col)) for col in zip(*items_as_arrays)] for row in items_as_arrays...
orpus_frequency acc_word = count_map[word_freq] if word_freq in count_map else operationstats.OperationStatistics(str(word_freq)) acc_word.increment_all(op_stat) count_map[word_freq] = acc_word return list(count_map.values()) def write_array_list_to_file(filename, list_to_write):
64
64
137
12
52
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
write_array_list_to_file
write_array_list_to_file
83
95
83
83
e79f5cbdd5e66ec8b5aaf17c03966d190a7908a2
bigcode/the-stack
train
e763c3d0b63fc42541088e05
train
function
def parse_args(): parser = argparse.ArgumentParser(description='Statistics on Kaldi ops file by corpus frequency', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('i', type=argparse.FileType('r'), help='Kaldi ops file') parser.add_argument('f'...
def parse_args():
parser = argparse.ArgumentParser(description='Statistics on Kaldi ops file by corpus frequency', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('i', type=argparse.FileType('r'), help='Kaldi ops file') parser.add_argument('f', type=argparse.Fi...
ref, hyp, count_str = line.split() count = int(count_str) ref_hyp = {'ref': ref, 'hyp': hyp} result_maps.add_operation(ref_hyp, freq_map, operation, count) write_results(result_maps, out_dir, top_freq) def parse_args():
64
64
131
4
60
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
parse_args
parse_args
169
177
169
169
4f890da9714ba4c29bccda4e96eda23c8518b082
bigcode/the-stack
train
9bfb922a94be0ff4a9e37b2a
train
function
def analyse_by_corpus_frequency(ops_list, freq_file, out_dir, top_freq): freq_map = init_frequency_map(freq_file) result_maps = WordMaps() for line in ops_list: operation, ref, hyp, count_str = line.split() count = int(count_str) ref_hyp = {'ref': ref, 'hyp': hyp} result_...
def analyse_by_corpus_frequency(ops_list, freq_file, out_dir, top_freq):
freq_map = init_frequency_map(freq_file) result_maps = WordMaps() for line in ops_list: operation, ref, hyp, count_str = line.split() count = int(count_str) ref_hyp = {'ref': ref, 'hyp': hyp} result_maps.add_operation(ref_hyp, freq_map, operation, count) write_results...
less freq word with more freq word: ' + str(result_maps.counter_lt_with_gt)) print('Substitutions of a more freq word with a les freq word: ' + str(result_maps.counter_gt_with_lt)) def analyse_by_corpus_frequency(ops_list, freq_file, out_dir, top_freq):
64
64
106
19
45
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
analyse_by_corpus_frequency
analyse_by_corpus_frequency
153
166
153
154
404267a24a428c4a5b2565ddb0fd07ca9e4bdd59
bigcode/the-stack
train
51ac987831f1a595aaf8f0a5
train
function
def init_frequency_map(freq_file): freq_map = {} for line in freq_file.readlines(): word, freq = line.split() freq_map[word] = int(freq) return freq_map
def init_frequency_map(freq_file):
freq_map = {} for line in freq_file.readlines(): word, freq = line.split() freq_map[word] = int(freq) return freq_map
(width) for val, width in zip(row, widths))) + '\n') out_file.close() def write_file(filename, list_to_write): with open(filename, 'w') as f: for line in list_to_write: f.write(line + '\n') def init_frequency_map(freq_file):
64
64
42
7
57
bnika/ice-kaldi
error-analysis/errors_by_frequency.py
Python
init_frequency_map
init_frequency_map
104
109
104
104
6fa6dc567b87d9b61907340c734d291a39bd3162
bigcode/the-stack
train
7dae1d0eebbc3fb54e66fb33
train
class
class TestSPHFile(unittest.TestCase): pytest.mark.skipif( not os.path.exists(CAMERON_SAMPLE), reason='Missing James Cameron Sample from TEDLium', ) def test_extract(self): sph = sphfile.SPHFile(CAMERON_SAMPLE) target = CAMERON_SAMPLE[:-4]+'-extract.wav' sph.write_wav...
class TestSPHFile(unittest.TestCase):
pytest.mark.skipif( not os.path.exists(CAMERON_SAMPLE), reason='Missing James Cameron Sample from TEDLium', ) def test_extract(self): sph = sphfile.SPHFile(CAMERON_SAMPLE) target = CAMERON_SAMPLE[:-4]+'-extract.wav' sph.write_wav(target, 111.29, 123.57) print(...
import unittest, pytest, os, glob from sphfile import sphfile import io HERE = os.path.dirname(os.path.abspath(__file__)) CAMERON_SAMPLE = os.path.join(HERE, 'JamesCameron_2010.sph') class TestSPHFile(unittest.TestCase):
61
143
477
9
52
mcfletch/sphfile
tests/test_sphfile.py
Python
TestSPHFile
TestSPHFile
9
69
9
10
ab28d90f7d6a6fe9a468ee3bffb66cfd077d18ba
bigcode/the-stack
train
19b68a3a2be3c3332a5188cf
train
function
def test_japser(host): assert host.file("/etc/init.d/rpc_jasperd").exists
def test_japser(host):
assert host.file("/etc/init.d/rpc_jasperd").exists
import os import testinfra.utils.ansible_runner testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner( os.environ['MOLECULE_INVENTORY_FILE'] ).get_hosts('all') def test_japser(host):
53
64
23
7
46
mongodb-ansible-roles/ansible-role-jasper
molecule/default/tests/test_default.py
Python
test_japser
test_japser
10
11
10
10
c951bf9f1824c50b70e834d5209e206cd9b65547
bigcode/the-stack
train
04f5a5b0247334bac2a684c6
train
class
class SignedObjectTests(unittest.TestCase): def setUp(self): self.expected = base64.b64encode(brreg_change_report.encode("utf-8")) @staticmethod def test_invalid_input(): with pytest.raises(TypeError): fVM.create_signed_object(None) with pytest.raises(ValueError): ...
class SignedObjectTests(unittest.TestCase):
def setUp(self): self.expected = base64.b64encode(brreg_change_report.encode("utf-8")) @staticmethod def test_invalid_input(): with pytest.raises(TypeError): fVM.create_signed_object(None) with pytest.raises(ValueError): fVM.create_signed_object(malformed_x...
legg> <vedleggsType>SGDK</vedleggsType> </vedlegg> <signerer>17033900562</signerer> </melding> </integrasjonERFV>""" # NOQA SECRET = "Secret" class SignedObjectTests(unittest.TestCase):
64
64
104
8
56
unicornis/pybrreg
tests/test_frivintVerifisertMelding.py
Python
SignedObjectTests
SignedObjectTests
314
332
314
315
09cbe12ebdbe96a874b52576073f2a22f5336e63
bigcode/the-stack
train
1206d561248786fced098ae3
train
class
class SignatureRecordTests(unittest.TestCase): def setUp(self): self.secret = "Secret" encoded_auth = base64.b64encode(authentication) signed_object_hash = fVM.create_signed_object_hash(brreg_change_report) signature = frivintVerifisertMelding.SignatureRecord() signature.Si...
class SignatureRecordTests(unittest.TestCase):
def setUp(self): self.secret = "Secret" encoded_auth = base64.b64encode(authentication) signed_object_hash = fVM.create_signed_object_hash(brreg_change_report) signature = frivintVerifisertMelding.SignatureRecord() signature.SignedObjectHash = signed_object_hash sign...
Somestring", self.secret) with pytest.raises(TypeError): fVM.create_record_seal(authentication, self.signed_object_hash, None) with pytest.raises(ValueError): fVM.create_record_seal(malformed_xml, self.signed_object_hash, self.secret) def test_valid_result(self): ...
118
118
396
8
110
unicornis/pybrreg
tests/test_frivintVerifisertMelding.py
Python
SignatureRecordTests
SignatureRecordTests
405
462
405
406
cfba02273ccaf7f572bee6c8ccce898fd9592e32
bigcode/the-stack
train
e25386171ebbd5e23fb726ef
train
class
class SignedObjectHashTests(unittest.TestCase): def setUp(self): hashed = hashlib.sha256(base64.b64encode(brreg_change_report.encode("utf-8"))) encoded = base64.b64encode(hashed.digest()) signed_object_hash = frivintVerifisertMelding.SignedObjectHash(encoded, algorithm="SHA-256") ...
class SignedObjectHashTests(unittest.TestCase):
def setUp(self): hashed = hashlib.sha256(base64.b64encode(brreg_change_report.encode("utf-8"))) encoded = base64.b64encode(hashed.digest()) signed_object_hash = frivintVerifisertMelding.SignedObjectHash(encoded, algorithm="SHA-256") self.expected = signed_object_hash.toxml(element...
): fVM.create_signed_object(None) with pytest.raises(ValueError): fVM.create_signed_object(malformed_xml) def test_valid_result(self): result = fVM.create_signed_object(brreg_change_report) self.assertEqual(self.expected, result) class SignedObjectHashTests(unitte...
64
64
180
9
55
unicornis/pybrreg
tests/test_frivintVerifisertMelding.py
Python
SignedObjectHashTests
SignedObjectHashTests
335
361
335
336
e51608243b782820884a7afc517a65d1713d823a
bigcode/the-stack
train
3e6dde322e651e3443d1071b
train
class
class RecordSealTests(unittest.TestCase): def setUp(self): self.secret = "Secret" self.signed_object_hash = fVM.create_signed_object_hash(brreg_change_report) hashed = hashlib.sha512() hashed.update(self.signed_object_hash.value()) hashed.update(base64.b64encode(authentica...
class RecordSealTests(unittest.TestCase):
def setUp(self): self.secret = "Secret" self.signed_object_hash = fVM.create_signed_object_hash(brreg_change_report) hashed = hashlib.sha512() hashed.update(self.signed_object_hash.value()) hashed.update(base64.b64encode(authentication)) hashed.update(self.secret) ...
Error): fVM.create_signed_object_hash(None) with pytest.raises(ValueError): fVM.create_signed_object_hash(malformed_xml) def test_valid_result(self): signed_object_hash = fVM.create_signed_object_hash(brreg_change_report) result = signed_object_hash.toxml(element_...
84
84
280
8
76
unicornis/pybrreg
tests/test_frivintVerifisertMelding.py
Python
RecordSealTests
RecordSealTests
364
402
364
365
332656f7865afa7c6fc80026c6c4cdf59b680ae1
bigcode/the-stack
train
e531af8fed6c96632623e154
train
class
class KerasOptimizersTest(test.TestCase): def _test_optimizer(self, optimizer, target=0.75): np.random.seed(1337) (x_train, y_train), _ = testing_utils.get_test_data( train_samples=1000, test_samples=200, input_shape=(10,), num_classes=2) y_train = keras.utils.to_categorical(y_train) model = ...
class KerasOptimizersTest(test.TestCase):
def _test_optimizer(self, optimizer, target=0.75): np.random.seed(1337) (x_train, y_train), _ = testing_utils.get_test_data( train_samples=1000, test_samples=200, input_shape=(10,), num_classes=2) y_train = keras.utils.to_categorical(y_train) model = _get_model(x_train.shape[1], 20, y_train.sh...
2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License...
256
256
1,732
10
245
jthorn22/tensorflow
tensorflow/python/keras/optimizers_test.py
Python
KerasOptimizersTest
KerasOptimizersTest
47
225
47
48
6e56bc2e05fe265238c3f0a70ce975005381a475
bigcode/the-stack
train
99cb1795c67547e999d2ae72
train
function
def _get_model(input_dim, num_hidden, output_dim): model = keras.models.Sequential() model.add(keras.layers.Dense(num_hidden, activation='relu', input_shape=(input_dim,))) model.add(keras.layers.Dense(output_dim, activation='softmax')) return model
def _get_model(input_dim, num_hidden, output_dim):
model = keras.models.Sequential() model.add(keras.layers.Dense(num_hidden, activation='relu', input_shape=(input_dim,))) model.add(keras.layers.Dense(output_dim, activation='softmax')) return model
tf2 from tensorflow.python.eager import context from tensorflow.python.framework import ops from tensorflow.python.framework import test_util from tensorflow.python.keras import testing_utils from tensorflow.python.platform import test from tensorflow.python.training.adam import AdamOptimizer def _get_model(input_dim,...
64
64
62
13
50
jthorn22/tensorflow
tensorflow/python/keras/optimizers_test.py
Python
_get_model
_get_model
38
44
38
38
e7047a0b9326006f79bd30fd763cf3e2f292648d
bigcode/the-stack
train
c49516610f489baf55c9e6c0
train
class
@test_util.run_all_in_graph_and_eager_modes class KerasV2OptimizersTest(test.TestCase, parameterized.TestCase): @parameterized.named_parameters( ('adadelta_tf2', 'adadelta', True), ('adadelta_tf1', 'adadelta', False), ('adagrad_tf2', 'adagrad', True), ('adagrad_tf1', 'adagrad', False), ('adam_tf2',...
@test_util.run_all_in_graph_and_eager_modes class KerasV2OptimizersTest(test.TestCase, parameterized.TestCase): @parameterized.named_parameters( ('adadelta_tf2', 'adadelta', True), ('adadelta_tf1', 'adadelta', False), ('adagrad_tf2', 'adagrad', True), ('adagrad_tf1', 'adagrad', False), ('adam_tf2',...
def test_load_from_string(self, optimizer_string, tf2mode): old_mode = os.environ.get('TF2_BEHAVIOR', None) if tf2mode: os.environ['TF2_BEHAVIOR'] = 'enabled' else: if 'TF2_BEHAVIOR' in os.environ: del os.environ['TF2_BEHAVIOR'] # Sanity check. self.assertEqual(tf2.enabled(), ...
@test_util.run_all_in_graph_and_eager_modes class KerasV2OptimizersTest(test.TestCase, parameterized.TestCase): @parameterized.named_parameters( ('adadelta_tf2', 'adadelta', True), ('adadelta_tf1', 'adadelta', False), ('adagrad_tf2', 'adagrad', True), ('adagrad_tf1', 'adagrad', False), ('adam_tf2',...
214
123
412
214
0
jthorn22/tensorflow
tensorflow/python/keras/optimizers_test.py
Python
KerasV2OptimizersTest
KerasV2OptimizersTest
228
260
228
238
7ed64b93670d793b8d5cfed4e3159f777dfb09a7
bigcode/the-stack
train
5cc196d4e52307c1ed907311
train
class
class RoleViewSet(mixins.UpdateModelMixin, mixins.DestroyModelMixin, mixins.RetrieveModelMixin, utils.CustomViewSetMixin, GenericViewSet): queryset = models.Role.objects.all() # pylint: disable=E1101 serializer_mapping = ( utils.S...
class RoleViewSet(mixins.UpdateModelMixin, mixins.DestroyModelMixin, mixins.RetrieveModelMixin, utils.CustomViewSetMixin, GenericViewSet):
queryset = models.Role.objects.all() # pylint: disable=E1101 serializer_mapping = ( utils.SerializerMapping .from_module(serializers.users.roles) .extend( add_permission=serializers.users.roles.SelectPermissionSerializer, remove_permission=serializers.users.role...
_api import utils from irekua_rest_api.permissions import ReadOnly from irekua_rest_api.permissions import IsAdmin class RoleViewSet(mixins.UpdateModelMixin, mixins.DestroyModelMixin, mixins.RetrieveModelMixin, utils.CustomViewSetMixin, GenericVie...
64
64
187
38
25
IslasGECI/irekua-rest-api
irekua_rest_api/views/users/roles.py
Python
RoleViewSet
RoleViewSet
18
43
18
22
805bb03b6b2ef74012c26fb199add7e767608552
bigcode/the-stack
train
802e5380afb0bdceeeda4609
train
function
def t_COMENTARIO_SIMPLE(t): r'--.*\n' t.lexer.lineno += 1
def t_COMENTARIO_SIMPLE(t):
r'--.*\n' t.lexer.lineno += 1
return t # Comentario de múltiples líneas /* .. */ def t_COMENTARIO_MULTILINEA(t): r'/\*(.|\n)*?\*/' t.lexer.lineno += t.value.count('\n') # Comentario simple // ... def t_COMENTARIO_SIMPLE(t):
64
64
26
8
56
webdev188/tytus
parser/team22/gramatica.py
Python
t_COMENTARIO_SIMPLE
t_COMENTARIO_SIMPLE
179
181
179
179
b693eda58c102b85ee99e5ccbb3b090fbfeece8c
bigcode/the-stack
train
b7a96dede9db166b2d1de5b8
train
function
def t_error(t): print("Illegal character '%s'" % t.value[0]) t.lexer.skip(1)
def t_error(t):
print("Illegal character '%s'" % t.value[0]) t.lexer.skip(1)
(t): r'--.*\n' t.lexer.lineno += 1 # Caracteres ignorados t_ignore = " \t" def t_newline(t): r'\n+' t.lexer.lineno += t.value.count("\n") def t_error(t):
63
64
27
5
58
webdev188/tytus
parser/team22/gramatica.py
Python
t_error
t_error
190
192
190
190
c7bbd49902aa4a5e7600daf90ea894ae0b63ff19
bigcode/the-stack
train
c2d4efda8041df5ce40e1a35
train
function
def p_instruccion_selects(t) : '''selects : POR FROM select_all | lista_parametros FROM ID PTCOMA''' print("selects")
def p_instruccion_selects(t) :
'''selects : POR FROM select_all | lista_parametros FROM ID PTCOMA''' print("selects")
def p_instruccion_Use_BD(t) : 'cambio_bd : ID PTCOMA' t[0] = Cambio_BD(t[1]) print("CAMBIO de BD") # INSTRUCCIONES CON "SELECT" def p_instruccion_selects(t) :
64
64
38
10
54
webdev188/tytus
parser/team22/gramatica.py
Python
p_instruccion_selects
p_instruccion_selects
268
271
268
268
3bee9ac710b0507685793c7a819b1787541f4b82
bigcode/the-stack
train
8302eeceb9e55fccb84964ad
train
function
def p_error(t): print(t) print("Error sintáctico en '%s'" % t.value)
def p_error(t):
print(t) print("Error sintáctico en '%s'" % t.value)
Delete_incondicional(t[1]) def p_instruccion_delete_condicional(t) : 'delete_condicional : ID WHERE PTCOMA' # t[0] = Delete_incondicional(t[1]) print("Eliminar tabla: " + t[1]) def p_error(t):
64
64
24
5
59
webdev188/tytus
parser/team22/gramatica.py
Python
p_error
p_error
344
346
344
344
28587525e0b8c86ddf9ff19989b7ca74ef2b0ffd
bigcode/the-stack
train
5bdbf8566d7c4aa7fb11f268
train
function
def t_ID(t): r'[a-zA-Z_][a-zA-Z_0-9]*' t.type = reservadas.get(t.value.lower(),'ID') # Check for reserved words return t
def t_ID(t):
r'[a-zA-Z_][a-zA-Z_0-9]*' t.type = reservadas.get(t.value.lower(),'ID') # Check for reserved words return t
0 return t def t_ENTERO(t): r'\d+' try: t.value = int(t.value) except ValueError: print("Integer value too large %d", t.value) t.value = 0 return t def t_ID(t):
64
64
48
5
58
webdev188/tytus
parser/team22/gramatica.py
Python
t_ID
t_ID
163
166
163
163
5528e2f3bccdc7b8a3e5e5006921a15c0892be21
bigcode/the-stack
train
dce6d4d5e8d7eb76b73e03a2
train
function
def p_parametro_sin_tabla(t) : 'parametro : ID' t[0] = t[1] print("Parametro SIN indice de tabla")
def p_parametro_sin_tabla(t) :
'parametro : ID' t[0] = t[1] print("Parametro SIN indice de tabla")
] = t[1] print("Parametro con indice de tabla") def p_parametro_con_tabla_columna(t) : 'name_column : ID' t[0] = t[1] print("Nombre de la columna") def p_parametro_sin_tabla(t) :
64
64
38
11
53
webdev188/tytus
parser/team22/gramatica.py
Python
p_parametro_sin_tabla
p_parametro_sin_tabla
301
304
301
301
e4bcbb25a393a38a1bf3bd802741388300a868e7
bigcode/the-stack
train