rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
elif event.key == ' ': print "Reloading..." plt.clf() tempo_results = TempoResults(options.freqbands) plot_data(tempo_results, options.xaxis, options.yaxis, options.postfit, options.prefit, options.mark_peri, \ options.legend) | elif event.key.lower() == 'u': changed = False print "Setting units. User input required..." axis = raw_input("Which axis (x/y)? ") if axis in ('x', 'X'): xunits = raw_input("Units for X-axis " \ "(numtoa/mjd/year/orbitphase): ") if xunits.lower() in ('numtoa', 'mjd', 'year', 'orbitphase'): changed = (xunits != option... | def keypress(event): global tempo_results global options if type(event.key) == types.StringType: if event.key.lower() == 'q': quit() elif event.key.lower() == 's': savefigure() elif event.key.lower() == 'z': # Turn on zoom mode print "Toggling zoom mode..." event.canvas.toolbar.zoom() elif event.key.lower() == 'o': # ... |
create_plot(tempo_results, options.xaxis, options.yaxis, options.postfit, \ options.prefit, options.interactive, options.mark_peri, \ options.legend) | create_plot() reloadplot() if options.interactive: fig = plt.gcf() cid_keypress = fig.canvas.mpl_connect('key_press_event', keypress) cid_pick = fig.canvas.mpl_connect('pick_event', pick) plt.ion() plt.show() else: savefigure() quit() | def main(): global tempo_results global options options = parse_options() tempo_results = TempoResults(options.freqbands) create_plot(tempo_results, options.xaxis, options.yaxis, options.postfit, \ options.prefit, options.interactive, options.mark_peri, \ options.legend) |
parser = optparse.OptionParser() parser.add_option('-f', '--freq', dest='freqs', action='append', help="Band of frequencies, in MHz, to be plotted (format xxx:yyy). Each band will have a different colour. Multiple -f/--freq options are allowed. (Default: Plot all frequencies in single colour.)", default=[]) parser.add_... | parser = optparse.OptionParser(prog="pyplotres.py", \ version="v1.1 Patrick Lazarus (Mar. 13, 2010)") parser.add_option('-f', '--freq', dest='freqs', action='append', \ help="Band of frequencies, in MHz, to be plotted " \ "(format xxx:yyy). Each band will have a " \ " different colour. Multiple -f/--freq options " \ " ... | def main(): global tempo_results global options options = parse_options() tempo_results = TempoResults(options.freqbands) create_plot(tempo_results, options.xaxis, options.yaxis, options.postfit, \ options.prefit, options.interactive, options.mark_peri, \ options.legend) |
month[E==14.0 or E==15.0] = E - 13 | month[(E==14.0) | (E==15.0)] = E - 13 | def JD_to_date(JD): """Convert Julian Day (JD) to a date. Input: JD: Julian day (Follow Jean Meeus' Astronomical Algorithms, 2nd Ed., Ch. 7) """ JD = np.atleast_1d(JD) if np.any(JD<0.0): raise ValueError("This function does not apply for JD < 0.") JD += 0.5 # Z is integer part of JD Z = np.floor(JD) # F is fractio... |
year[month==1.0 or month==2.0] = C - 4715 | year[(month==1.0) | (month==2.0)] = C - 4715 | def JD_to_date(JD): """Convert Julian Day (JD) to a date. Input: JD: Julian day (Follow Jean Meeus' Astronomical Algorithms, 2nd Ed., Ch. 7) """ JD = np.atleast_1d(JD) if np.any(JD<0.0): raise ValueError("This function does not apply for JD < 0.") JD += 0.5 # Z is integer part of JD Z = np.floor(JD) # F is fractio... |
scatt_psrs = ax.scatter(np.log10(periods), np.log10(pdots), c='k', s=6, \ | scatt_psrs = ax.scatter(periods, pdots, c='k', s=6, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
scatt_psrs_hl = ax.scatter(np.log10(periods_hl), np.log10(pdots_hl), \ | scatt_psrs_hl = ax.scatter(periods_hl, pdots_hl, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
scatt_binaries = ax.scatter(np.log10(periods_bnry), np.log10(pdots_bnry), \ | scatt_binaries = ax.scatter(periods_bnry, pdots_bnry, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
scatt_rrats = ax.scatter(np.log10(periods_rrat), np.log10(pdots_rrat), \ | scatt_rrats = ax.scatter(periods_rrat, pdots_rrat, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
scatt_magnetars = ax.scatter(np.log10(periods_mag), np.log10(pdots_mag), \ | scatt_magnetars = ax.scatter(periods_mag, pdots_mag, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
scatt_sgr = ax.scatter(np.log10(periods_sgr), np.log10(pdots_sgr), \ | scatt_sgr = ax.scatter(periods_sgr, pdots_sgr, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
scatt_axp = ax.scatter(np.log10(periods_axp), np.log10(pdots_axp), \ | scatt_axp = ax.scatter(periods_axp, pdots_axp, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
scatt_snrs = ax.scatter(np.log10(periods_snr), np.log10(pdots_snr), \ | scatt_snrs = ax.scatter(periods_snr, pdots_snr, \ | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
plt.xlabel("log Period") plt.ylabel(r"log $\mathsf{\dot P}$") | plt.xlabel("Period (s)") plt.ylabel(r"$\mathsf{\dot P}$ (s/s)") | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
plt.xlim(np.log10((0.001, 100))) plt.ylim(np.log10((10**-22, 10**-8))) | plt.xscale("log") plt.yscale("log") plt.xlim((0.001, 100)) plt.ylim((10**-22, 10**-8)) | def plot_data(pulsars, hightlight=[], binaries=False, rrats=False, \ magnetars=False, snrs=False, axp=False, sgr=False, \ edots=[], ages=[], bsurfs=[]): """Plot P-Pdot diagram using list of pulsars provided. binaries - boolean, initially plot binary markers rrats - boolean, initially plot RRAT markers magnetars - boole... |
periods = np.linspace(plimits[0], plimits[1], 100) pdots = np.linspace(pdotlimits[0], pdotlimits[1], 100) | periods = np.logspace(np.log10(plimits[0]), np.log10(plimits[1]), 100) pdots = np.logspace(np.log10(pdotlimits[0]), np.log10(pdotlimits[1]), 100) | def draw_lines(bfields=[], edots=[], ages=[], label=False): """Draw multiple lines of constant B-field, edot and age. """ plimits = plt.xlim() pdotlimits = plt.ylim() periods = np.linspace(plimits[0], plimits[1], 100) pdots = np.linspace(pdotlimits[0], pdotlimits[1], 100) bfield_vals = np.zeros((periods.size, pdots.siz... |
f, fdot = psr_utils.p_to_f(10**periods[i], 10**pdots[j]) | f, fdot = psr_utils.p_to_f(periods[i], pdots[j]) | def draw_lines(bfields=[], edots=[], ages=[], label=False): """Draw multiple lines of constant B-field, edot and age. """ plimits = plt.xlim() pdotlimits = plt.ylim() periods = np.linspace(plimits[0], plimits[1], 100) pdots = np.linspace(pdotlimits[0], pdotlimits[1], 100) bfield_vals = np.zeros((periods.size, pdots.siz... |
def savefigure(savefn='./ppdot.ps'): | def savefigure(savefn='./ppdot.png'): | def savefigure(savefn='./ppdot.ps'): print "Saving plot to %s" % savefn plt.savefig(savefn, orientation='landscape', papertype='letter') |
p = 10**(event.xdata) pdot = 10**(event.ydata) | p = event.xdata pdot = event.ydata | def mousepress(event): """Event handler for MouseEvent ('button_press_event'). """ if event.inaxes and event.button == 2: p = 10**(event.xdata) pdot = 10**(event.ydata) bfield, age, edot = params_from_ppdot(p, pdot) print "Coordinates:" print "\tPeriod (s): %g, P-dot (s/s): %g" % (p, pdot) print "\tB-field (G): %g" % b... |
course = FullTestCourse() | def __init__(self): methods = [m for m in dir(self.__class__) if not m.startswith('__')] | |
elixer.create_moodle_zip(course, 'out.zip') | if __name__ == '__main__': course = FullTestCourse() elixer.create_moodle_zip(course, 'out.zip') | def __init__(self): methods = [m for m in dir(self.__class__) if not m.startswith('__')] |
create_moodle_zip('in.zip', 'out.zip') | create_moodle_zip(blackboard_zip_name, moodle_zip_name) | def create_moodle_zip(blackboard_zip_fname, out_name): try: shutil.rmtree('elixer_tmp') shutil.rmtree('course_files') except OSError: pass course = Course(blackboard_zip_fname) moodle_zip = zipfile.ZipFile(out_name, 'w') moodle_xml_str = elixer.convert(course).encode('utf-8') moodle_zip.writestr('moodle.xml', moodl... |
title = res_xml.find('.//LABEL').attrib['value'] | title = content_area.getchildren()[0].text | def create_content_areas(self): sections = [] |
section['toc_id'] = res_xml.find | def create_content_areas(self): sections = [] | |
f_link = '<a href = "$@FILEPHP@$/%s" title = %s>%s' % ((fname,) * 3) f_link = 'Attached File: ' + f_link | link_name = file_elem.find('.//LINKNAME').attrib['value'] f_link = '<a href = "$@FILEPHP@$/%s" title = %s>' % ((fname,) * 2) f_link = 'Attached File: ' + f_link + '%s</a>' % link_name | def handle_file(self, file_elem): orig_name = file_elem.find('.//NAME').text |
a = self.xml.find('.//respcondition[@title="correct"]//varequal').text self.true_points, self.false_points = (1, 0) if a == 'true' else (0, 1) self.true_answer_id = elixer.m_hash(self, self.true_points) self.false_answer_id = elixer.m_hash(self, self.false_points) | answer_query = './/respcondition[@title="correct"]//varequal' answer_elem = self.xml.find(answer_query) if answer_elem is not None: a = answer_elem.text self.true_points, self.false_points = (1, 0) if a == 'true' else (0, 1) self.true_answer_id = elixer.m_hash(self, self.true_points) self.false_answer_id = elixer.m... | def _load(self): self.name = self.xml.find('.//presentation//mat_formattedtext').text self.text = self.name |
res_nums_to_assets[res_num].indent = indent res_nums_to_assets[res_num].section_num = section_num | try: res_nums_to_assets[res_num].indent = indent res_nums_to_assets[res_num].section_num = section_num except KeyError: continue | def recurse(elem, indent): children = elem.getchildren() |
fname = urllib2.quote(elixer.fix_filename(orig_name, self.res_num)) | fixed_name = elixer.fix_filename(orig_name, self.res_num) fname = urllib2.quote(fixed_name.encode('utf-8')) | def handle_file(self, file_elem): orig_name = file_elem.find('.//NAME').text |
self.sections = self.create_content_areas() self.sections += self.create_sections() | self.sections = self.create_default_sections() self.sections += self.create_content_areas() | def __init__(self, archive_filename): self.archive_filename = archive_filename |
def create_sections(self): | def create_content_areas(self): | def create_sections(self): sections = [] |
def create_content_areas(self): | def create_default_sections(self): | def create_content_areas(self): sections = [ {'number': 0, 'summary': '<h2>Announcements</h2>'}, {'number': 1, 'summary': '<h2>Forums</h2>'}, {'number': 2, 'summary': '<h2>Quizzes</h2>'}, ] |
self.resources = [] | def __init__(self, archive_filename): self.archive_filename = archive_filename | |
self.sections = self.create_sections() | self.sections = self.create_content_areas() self.sections += self.create_sections() | def __init__(self, archive_filename): self.archive_filename = archive_filename |
self.forums.append(DiscussionBoard(xml)) | self.forums.append(DiscussionBoard(xml, res_num)) | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
self.resources.append(Announcement(xml)) | self.resources.append(Announcement(xml, res_num)) | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
self.quizzes.append(Test(xml, quiz_questions)) | self.quizzes.append(Test(xml, quiz_questions, res_num)) | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
self.quizzes.append(Survey(xml, quiz_questions)) | self.quizzes.append(Survey(xml, quiz_questions, res_num)) | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
self.quizzes.append(Pool(xml, quiz_questions)) | self.quizzes.append(Pool(xml, quiz_questions, res_num)) | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
self.labels.append(Label(document.name)) | self.labels.append(Label(document.name, res_num)) | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
{'number': 3, 'summary': '<h2>Resources</h2>'}, | def create_sections(self): sections = [ {'number': 0, 'summary': '<h2>Announcements</h2>'}, {'number': 1, 'summary': '<h2>Forums</h2>'}, {'number': 2, 'summary': '<h2>Quizzes</h2>'}, {'number': 3, 'summary': '<h2>Resources</h2>'}, ] | |
def __init__(self, xml): | def __init__(self, xml, res_num): | def __init__(self, xml): if self.__class__ == 'Resource': raise NotImplementedError('Do not instantiate base class') |
def __init__(self, xml, res_num): self.res_num = res_num Resource.__init__(self, xml) | def __init__(self, xml, res_num): self.res_num = res_num | |
def __init__(self, name): | def __init__(self, name, res_num): | def __init__(self, name): self.name = self.content = name |
def __init__(self, xml, quiz_questions): Resource.__init__(self, xml) | def __init__(self, xml, quiz_questions, res_num): Resource.__init__(self, xml, res_num) | def __init__(self, xml, quiz_questions): Resource.__init__(self, xml) |
self.questions['essay'].append(EssayQuestion(xml)) | self.questions['essay'].append(EssayQuestion(question)) elif question_type == 'Short Response': self.questions['essay'].append(ShortResponseQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
elif question_type == 'Short Response': self.questions['essay'].append(ShortResponseQuestion(xml)) | def convert_questions(self, xml): questions = xml.findall('.//item') | |
self.questions['truefalse'].append(EitherOrQuestion(xml)) | self.questions['truefalse'].append(EitherOrQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
self.questions['truefalse'].append(TrueFalseQuestion(xml)) | self.questions['truefalse'].append(TrueFalseQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
self.questions['multichoice'].append(MultipleAnswerQuestion(xml)) | self.questions['multichoice'].append(MultipleAnswerQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
self.questions['multichoice'].append(MultipleChoiceQuestion(xml)) | self.questions['multichoice'].append(MultipleChoiceQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
self.questions['multichoice'].append(OpinionScaleQuestion(xml)) | self.questions['multichoice'].append(OpinionScaleQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
self.questions['matching'].append(MatchingQuestion(xml)) | self.questions['matching'].append(MatchingQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
self.questions['matching'].append(Ordering(xml)) | self.questions['matching'].append(Ordering(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
self.questions['shortanswer'].append(FillInTheBlankQuestion(xml)) | self.questions['shortanswer'].append(FillInTheBlankQuestion(question)) | def convert_questions(self, xml): questions = xml.findall('.//item') |
class ShortResponseQuestion(Question): def _load(self): pass | class ShortResponseQuestion(EssayQuestion): pass | def _load(self): e = self.xml.find('.//presentation').find('.//mat_formattedtext') |
return abs(hash(tuple(obj))) | return abs(hash(tuple(obj.values()))) | def m_hash(obj): if isinstance(obj, dict): return abs(hash(tuple(obj))) else: return abs(hash(tuple(obj.__dict__.values()))) |
for f in os.listdir('elixer_tmp'): if f.startswith('res') and os.path.isdir(os.path.join('elixer_tmp', f)): for inner_file in os.listdir(os.path.join('elixer_tmp', f)): res_num = f.replace('res', '') fixed_filename = elixer.fix_filename(inner_file, res_num) blackboard_filename = os.path.join('elixer_tmp', f, inner_fil... | skip_parent = False for root, dirs, files in os.walk('elixer_tmp'): if not skip_parent: skip_parent = True continue for fname in files: res_num = root.split(os.sep, 1)[1].split(os.sep)[0].replace('res', '') fixed_filename = elixer.fix_filename(fname, res_num) blackboard_filename = os.path.join(root, fname) moodle_... | def create_moodle_zip(blackboard_zip_fname, out_name): try: shutil.rmtree('elixer_tmp') shutil.rmtree('course_files') except OSError: pass course = Course(blackboard_zip_fname) moodle_zip = zipfile.ZipFile(out_name, 'w') moodle_xml_str = elixer.convert(course) moodle_zip.writestr('moodle.xml', moodle_xml_str) err_... |
if correct_elem: | if correct_elem is not None: | def build_answers(self): self.single_answer = 1 |
self.secondary_category = category_elems[1].attrib['value'] | try: self.secondary_category = category_elems[1].attrib['value'] except IndexError: self.secondary_category = '' | def convert_course_settings(self, xml): self.fullname = xml.find('.//TITLE').attrib['value'] self.shortname = self.fullname.replace(' ', '') |
ext, fname = [s[::-1] for s in bb_fname[1:][::-1].split('.', 1)] moodle_fname = (base64.b16decode(fname.upper()) + '.' + ext) | if '.' in bb_fname: ext, fname = [s[::-1] for s in bb_fname[1:][::-1].split('.', 1)] moodle_fname = (base64.b16decode(fname.upper()) + '.' + ext) else: ext, fname = '', bb_fname[1:] moodle_fname = (base64.b16decode(fname.upper())) | def create_moodle_zip(blackboard_zip_fname, out_name): try: shutil.rmtree('elixer_tmp') shutil.rmtree('course_files') except OSError: pass course = Course(blackboard_zip_fname) moodle_zip = zipfile.ZipFile(out_name, 'w') moodle_xml_str = elixer.convert(course).encode('utf-8') moodle_zip.writestr('moodle.xml', moodl... |
self.cor_fb = self.xml.find(query).text self.incor_fb = self.xml.find(query.replace('"c', '"inc')).text | try: self.cor_fb = self.xml.find(query).text self.incor_fb = self.xml.find(query.replace('"c', '"inc')).text except AttributeError: self.cor_fb = '' self.incor_fb = '' | def _load(self): self.name = self.xml.find('.//presentation//mat_formattedtext').text self.text = self.name |
correct_ident = self.xml.find(query).text for answer in self.answers: if answer['ident'] == correct_ident: | correct_elem = self.xml.find(query) if correct_elem: correct_ident = correct_elem.text for answer in self.answers: if answer['ident'] == correct_ident: answer['points'] = 1 answer['feedback'] = self.cor_fb else: answer['points'] = 0 answer['feedback'] = self.incor_fb answer['id'] = elixer.m_hash(answer) else: for an... | def build_answers(self): self.single_answer = 1 |
else: answer['points'] = 0 answer['feedback'] = self.incor_fb answer['id'] = elixer.m_hash(answer) | answer['id'] = elixer.m_hash(answer) | def build_answers(self): self.single_answer = 1 |
the_hash = abs(hash(tuple(args[0].__dict__.values()))) | the_hash = abs(hash(args[0])) | def m_hash(*args): # TODO: Refactor? if len(args) > 1: the_hash = abs(hash(args)) elif isinstance(args[0], dict): the_hash = abs(hash(tuple(args[0].values()))) else: the_hash = abs(hash(tuple(args[0].__dict__.values()))) return int(str(the_hash)[-8:]) |
return int(str(the_hash)[-8:]) | return int(str(the_hash)) | def m_hash(*args): # TODO: Refactor? if len(args) > 1: the_hash = abs(hash(args)) elif isinstance(args[0], dict): the_hash = abs(hash(tuple(args[0].values()))) else: the_hash = abs(hash(tuple(args[0].__dict__.values()))) return int(str(the_hash)[-8:]) |
if self.alltext and '@X@EmbeddedFile' in self.alltext: | if not self.alltext: self.alltext = '' while '@X@EmbeddedFile' in self.alltext: | def _load(self): self.content_id = self.xml.getroot().attrib['id'] self.name = self.xml.find('.//TITLE').attrib['value'] self.alltext = self.xml.find('.//TEXT').text self.ignore = False self.make_label = False |
if not self.alltext: self.alltext = '' | def handle_file(self, file_elem): orig_name = file_elem.find('.//NAME').text | |
before, rest = text.split('@X@EmbeddedFile.location@X@') | before, rest = text.split('@X@EmbeddedFile.location@X@', 1) | def handle_embedded_file(self, text): before, rest = text.split('@X@EmbeddedFile.location@X@') |
moodle_xml_str = elixer.convert(course) | moodle_xml_str = elixer.convert(course).encode('utf-8') | def create_moodle_zip(blackboard_zip_fname, out_name): try: shutil.rmtree('elixer_tmp') shutil.rmtree('course_files') except OSError: pass course = Course(blackboard_zip_fname) moodle_zip = zipfile.ZipFile(out_name, 'w') moodle_xml_str = elixer.convert(course) moodle_zip.writestr('moodle.xml', moodle_xml_str) err_... |
a = self.xml.find('.//respcondition[@title="correct"]//varequal').text ans_type = a.split('.')[0] true_points, false_points = (1, 0) if a.endswith('true') else (0, 1) right_ans = {} right_ans['answer_text'] = self.ans_types[ans_type][0] right_ans['points'] = true_points if true_points == 1: right_ans['feedback'] = ... | answer_query = './/respcondition[@title="correct"]//varequal' answer_elem = self.xml.find(answer_query) if answer_elem is not None: answer = answer_elem.text ans_type = answer.split('.')[0] true_points, false_points = (1, 0) if answer.endswith('true') else (0, 1) right_ans = {} right_ans['answer_text'] = self.ans_t... | def build_answers(self): self.single_answer = 1 |
right_ans['feedback'] = self.incor_fb right_ans['id'] = elixer.m_hash(right_ans) wrong_ans = {} wrong_ans['answer_text'] = self.ans_types[ans_type][1] wrong_ans['points'] = false_points if false_points == 1: wrong_ans['feedback'] = self.cor_fb else: wrong_ans['feedback'] = self.incor_fb wrong_ans['id'] = elixer.m_h... | right_ans = {} right_ans['answer_text'] = 'Agree' right_ans['points'] = 1 right_ans['feedback'] = '' right_ans['id'] = elixer.m_hash(right_ans) wrong_ans = {} wrong_ans['answer_text'] = 'Disagree' wrong_ans['points'] = 0 wrong_ans['feedback'] = '' wrong_ans['id'] = elixer.m_hash(wrong_ans) | def build_answers(self): self.single_answer = 1 |
sa_question['general_feedback'] = 'Gen feedback for tf | sa_question['general_feedback'] = 'Gen feedback for sa | def add_questions_shortanswer(self): shortanswer_questions = [] |
self.true_feedback = self.xml.find(query).text self.false_feedback = self.xml.find(query.replace('"c', '"inc')).text | true_fb_el = self.xml.find(query) false_fb_el = self.xml.find(query.replace('"c', '"inc')) self.true_feedback = true_fb_el.text if true_fb_el is not None else '' self.false_feedback = false_fb_el.text if false_fb_el is not None else '' | def _load(self): self.name = self.xml.find('.//presentation//mat_formattedtext').text self.text = self.name |
fname = elixer.fix_filename(orig_name, self.res_num) | fname = urllib2.quote(elixer.fix_filename(orig_name, self.res_num)) | def handle_file(self, file_elem): orig_name = file_elem.find('.//NAME').text |
def handle_file_encoding(self, filename): ext, filename = [s[::-1] for s in filename[::-1].split('.', 1)] filename = '!' + base64.b16encode(urllib.unquote(filename)) + '.' + ext return filename.lower() | def handle_file_encoding(self, filename): ext, filename = [s[::-1] for s in filename[::-1].split('.', 1)] | |
for fname in files: | for bb_fname in files: moodle_fname = bb_fname if bb_fname.startswith('!'): ext, fname = [s[::-1] for s in bb_fname[1:][::-1].split('.', 1)] moodle_fname = (base64.b16decode(fname.upper()) + '.' + ext) moodle_fname = urllib2.unquote(moodle_fname) | def create_moodle_zip(blackboard_zip_fname, out_name): try: shutil.rmtree('elixer_tmp') shutil.rmtree('course_files') except OSError: pass course = Course(blackboard_zip_fname) moodle_zip = zipfile.ZipFile(out_name, 'w') moodle_xml_str = elixer.convert(course).encode('utf-8') moodle_zip.writestr('moodle.xml', moodl... |
fixed_filename = elixer.fix_filename(fname, res_num) blackboard_filename = os.path.join(root, fname) moodle_filename = os.path.join('course_files', fixed_filename) moodle_zip.write(blackboard_filename, moodle_filename) | fixed_filename = elixer.fix_filename(moodle_fname, res_num) bb_fname = os.path.join(root, bb_fname) moodle_fname = os.path.join('course_files', fixed_filename) moodle_zip.write(bb_fname, moodle_fname) | def create_moodle_zip(blackboard_zip_fname, out_name): try: shutil.rmtree('elixer_tmp') shutil.rmtree('course_files') except OSError: pass course = Course(blackboard_zip_fname) moodle_zip = zipfile.ZipFile(out_name, 'w') moodle_xml_str = elixer.convert(course).encode('utf-8') moodle_zip.writestr('moodle.xml', moodl... |
type = resource.attrib['type'] if type == 'course/x-bb-coursesetting': | res_type = resource.attrib['type'] if res_type == 'course/x-bb-coursesetting': | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
elif type == 'resource/x-bb-discussionboard': | elif res_type == 'resource/x-bb-discussionboard': | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
elif type == 'resource/x-bb-announcement': | elif res_type == 'resource/x-bb-announcement': | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
elif type == 'assessment/x-bb-qti-test': | elif res_type == 'assessment/x-bb-qti-test': | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
elif type == 'assessment/x-bb-qti-survey': | elif res_type == 'assessment/x-bb-qti-survey': | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
elif type == 'assessment/x-bb-qti-pool': | elif res_type == 'assessment/x-bb-qti-pool': | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
elif type == 'resource/x-bb-document': | elif res_type == 'resource/x-bb-document': | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
query = './/itemfeedback[@ident="correct"]//mat_formattedtext' cor_fb = self.xml.find(query).text incor_fb = self.xml.find(query.replace('"c', '"inc')).text | def _load(self): self.name = self.xml.find('.//presentation//mat_formattedtext').text self.text = self.name | |
dat_name = content_area.attrib['identifierref'] + '.dat' | try: dat_name = content_area.attrib['identifierref'] + '.dat' except KeyError: continue | def create_content_areas(self): sections = [] |
while '@X@EmbeddedFile' in self.alltext: | while '@X@EmbeddedFile.location@X@' in self.alltext: | def _load(self): self.content_id = self.xml.getroot().attrib['id'] self.name = self.xml.find('.//TITLE').attrib['value'] self.alltext = self.xml.find('.//TEXT').text self.ignore = False self.make_label = False |
self.intro = 'something' if self.intro == '<br /><br />' else self.intro | self.intro = '' if self.intro == '<br /><br />' else self.intro | def _load(self): self.name = self.xml.find('.//assessment').attrib['title'] |
notes = self.xml.find('.//TEXT').text image = elixer.fix_filename(image, self.res_num) | notes = self.xml.find('.//TEXT').text or '' if image: image = elixer.fix_filename(image, self.res_num) | def _load(self): parts = ('FORMALTITLE', 'GIVEN', 'FAMILY') data_parts = [self.xml.find('.//%s' % p).attrib['value'] for p in parts] |
''' % (self.name, email, phone, hours, address, homepage, image, notes) | ''' % notes | def _load(self): parts = ('FORMALTITLE', 'GIVEN', 'FAMILY') data_parts = [self.xml.find('.//%s' % p).attrib['value'] for p in parts] |
xml = etree.parse(self.zip.open(dat_name)) | try: xml = etree.parse(self.zip.open(dat_name)) except KeyError: continue | def convert_resources(self): for resource in self.manifest.iterfind('.//resource'): dat_name = resource.attrib['file'] xml = etree.parse(self.zip.open(dat_name)) |
pass | c.join(e.arguments()[0]) def on_action(self, c, e): user = nm_to_n(e.source()) action = e.arguments()[0] channel = e.target() color = gen_color(user) self.write(channel, self.format["action"].replace("%user%", user) \ .replace("%action%", action) \ .replace("%color%", color)) | def on_invite(self, c, e): pass |
pass | c.privmsg(nm_to_n(e.source()), self.format["help"]) | def on_privmsg(self, c, e): pass |
date = strftime("%d-%m-%Y") | date = strftime("%Y-%m-%d") | def write(self, channel, message): time = strftime("%H:%M:%S") date = strftime("%d-%m-%Y") if channel: print "%s> %s %s" % (channel, time, message) channels = [channel] else: # Quit/nick don't have channels print "%s %s" % (time, message) channels = self.chans |
"quit", "topic"] | "quit", "topic", "action"] | def main(conf): """ Start the bot using a config file. :Parameters: - `conf`: config file location """ CONFIG = ConfigParser() CONFIG.read(conf) # Get the irc network configuration server = CONFIG.get("irc", "server") port = CONFIG.getint("irc", "port") channels = CONFIG.get("irc", "channels").split(",") nick = CONFI... |
bot.start() | try: bot.start() except KeyboardInterrupt: pass | def main(conf): """ Start the bot using a config file. :Parameters: - `conf`: config file location """ CONFIG = ConfigParser() CONFIG.read(conf) # Get the irc network configuration server = CONFIG.get("irc", "server") port = CONFIG.getint("irc", "port") channels = CONFIG.get("irc", "channels").split(",") nick = CONFI... |
.replace("%message%", message)) | .replace("%message%", message) \ .replace("%color%", color)) | def on_pubmsg(self, c, e): user = nm_to_n(e.source()) message = e.arguments()[0] channel = e.target() self.write(channel, self.format["pubmsg"].replace("%user%", user) \ .replace("%message%", message)) |
if not chans: | if not chans or not chans.startswith(" | def write_event(self, name, event, params={}): # Format the event properly chans = event.target() msg = self.format_event(name, event, params) # Quit goes across all channels if not chans: chans = self.chans else: chans = [chans] for chan in chans: self.append_log_msg(chan, msg) |
modes, person = e.arguments() | modes, person = e.arguments()[:2] | def on_mode(self, c, e): modes, person = e.arguments() channel = e.target() giver = nm_to_n(e.source()) self.write(channel, self.format["mode"].replace("%channel%", channel) \ .replace("%modes%", modes) \ .replace("%person%", person) \ .replace("%giver%", giver)) |
print "Uploading to FTP..." | def write_event(self, name, event, params={}): # Format the event properly chans = event.target() msg = self.format_event(name, event, params) # Quit goes across all channels if not chans or not chans.startswith("#"): chans = self.chans else: chans = [chans] for chan in chans: self.append_log_msg(chan, msg) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.