예제 #1
0
def program_form(category, id):
    if id == "new" and category == "none":
        return render_template('pages/program-form.html',
                               quote=helpers.quote(random.randint(0, 5)),
                               title="Program Form")
    else:
        return render_template('pages/program-form.html',
                               item=mongo.db[category].find_one(
                                   {'_id': ObjectId(id)}),
                               quote=helpers.quote(random.randint(0, 5)))
예제 #2
0
def update_stream_info(part):
    if config.mediainfo_bin and part.container == "mp4":
        cmdline = '%s --Inform="Text;-%%ID%%_%%Title%%" %s' % (
            config.mediainfo_bin, helpers.quote(part.file))
        result = subprocess.check_output(cmdline,
                                         stderr=subprocess.PIPE,
                                         shell=True)
        if result:
            try:
                stream_titles = {}
                for pair in result[1:].split("-"):
                    sid, title = pair.split("_")
                    stream_titles[int(sid.strip())] = title.strip()
            except:
                pass
            else:
                filled = []
                for stream in part.streams:
                    index = stream.index + 1
                    if index in stream_titles:
                        stream.title = stream_titles[index]
                        filled.append(index - 1)
                if filled:
                    Log.Debug(
                        "Filled missing MP4 stream title info for streams: %s",
                        filled)
예제 #3
0
 def open_command(*repl_args):
     command = copy.copy(_command)
     if pre_hook:
         # might want to pass repl_args to the pre_hook
         pre_hook(command)
     to_run = [OPEN]
     if "app" in command:
         to_run.extend(["-a", command["app"]])
     repl_args = [arg for arg in repl_args if arg]
     args = command.get("args", [])
     for arg in args:
         if arg.count("%s") == 1:
             if len(repl_args) == 1:
                 arg = arg % helpers.quote(repl_args)
             else:
                 arg = arg % helpers.quote(mac.pbpaste())
         if arg.startswith("~"):
             arg = helpers.expand_path(arg)
         to_run.append(arg)
     helpers.run(to_run)
예제 #4
0
def workouts(programId):
    program = mongo.db.programs.find_one({'_id': ObjectId(programId)})
    workouts = []

    for workoutId in json.loads(program["multiSelect"]):
        if workoutId is not "":
            workouts.append(ObjectId(workoutId))

    return render_template("pages/workouts.html",
                           workout=mongo.db.workouts.find(
                               {'_id': {
                                   '$in': workouts
                               }}),
                           program=program,
                           quote=helpers.quote(random.randint(0, 5)))
예제 #5
0
def index():
    """Show quote of the day"""

    quoteList = quote()

    #Generates a random number for the index of the list of quotes
    index = random.randint(1, 50)

    #Makes sure that anonymous is displayed if there is no author
    if quoteList[index]["author"] == None:
        quoteList[index]["author"] = "Anonymous"

    author = quoteList[index]["author"]
    text = quoteList[index]["text"]

    return render_template("index.html", text=text, author=author)
예제 #6
0
def exercises(programId, workoutId):
    workout = mongo.db.workouts.find_one({'_id': ObjectId(workoutId)})
    exercises = []

    for exerciseId in json.loads(workout["multiSelect"]):
        if exerciseId is not "":
            exercises.append(ObjectId(exerciseId))

    result = list(mongo.db.exercises.find({'_id': {'$in': exercises}}))
    muscleGroups = []

    for item in result:
        for muscle in json.loads(item["multiSelect"]):
            if muscle != "":
                if muscle not in muscleGroups:
                    muscleGroups.append(muscle)

    meta = mongo.db.exercises.aggregate([{
        "$match": {
            "_id": {
                '$in': exercises
            }
        }
    }, {
        "$group": {
            "_id": "0",
            "durationSum": {
                "$sum": "$exerciseDuration"
            },
            "difficultySum": {
                "$sum": "$exerciseDifficulty"
            },
            "count": {
                "$sum": 1
            }
        }
    }])

    return render_template("pages/exercises.html",
                           exercises=result,
                           muscleGroups=muscleGroups,
                           workout=workout,
                           meta=list(meta),
                           quote=helpers.quote(random.randint(0, 5)))
예제 #7
0
def programs():
    return render_template("pages/programs.html",
                           programs=mongo.db.programs.find(),
                           quote=helpers.quote(random.randint(0, 5)))
예제 #8
0
def make_title_page(work: Work,
                    common_info: Dict[str, str]) -> Tuple[str, Document]:
    document = Document()
    caption_paragraphs = list()
    topic_paragraphs = list()
    persons_paragraph = list()
    caption_paragraphs.append(
        document.add_paragraph(
            'Министерство образования и науки Российской Федерации'))
    caption_paragraphs.append(
        document.add_paragraph(
            'Федеральное государственное бюджетное учреждение'))
    caption_paragraphs.append(document.add_paragraph('высшего образования'))
    caption_paragraphs.append(document.add_paragraph(quote(__university__)))
    caption_paragraphs.append(document.add_paragraph())

    caption_paragraphs.append(
        document.add_paragraph('Факультет: {}'.format(common_info['faculty'])))
    caption_paragraphs.append(
        document.add_paragraph('Кафедра {}'.format(quote(
            common_info['chair']))))

    document.add_paragraph()
    document.add_paragraph()

    type_desc = __work_type_desc__[int(work['work_type'])]
    topic_paragraphs.append(document.add_paragraph(type_desc))

    if work['work_type'] == 7:
        topic_paragraphs.append(document.add_paragraph('на тему:'))
        topic_paragraphs.append(document.add_paragraph(quote(work['topic'])))
    if work['work_type'] == 8:
        discipline = work['discipline_code'] + ' ' + quote(work['discipline'])
        # 'Б.1.1.7 ' + quote('Информатика')
        direction = work['group_code'] + quote(work['study'])
        dir_profile = work['profile']
        qualification = work['qual']
        var = work['variant'] if 'variant' in work.keys() else 0
        topic_paragraphs.append(
            document.add_paragraph('по дисциплине {}'.format(discipline)))
        topic_paragraphs.append(
            document.add_paragraph(
                'направление подготовки {}'.format(direction)))
        topic_paragraphs.append(
            document.add_paragraph('профиль {}'.format(dir_profile)))
        topic_paragraphs.append(
            document.add_paragraph(
                'Квалификация (степень) {}'.format(qualification)))
        topic_paragraphs.append(
            document.add_paragraph('Тема {} Вариант {}'.format(
                quote(work['topic']), var)))

    document.add_paragraph()
    document.add_paragraph()
    document.add_paragraph()
    document.add_paragraph()

    persons_paragraph.append(document.add_paragraph('Выполнил:'))
    persons_paragraph.append(
        document.add_paragraph('студент группы {}'.format(work['group'])))
    persons_paragraph.append(document.add_paragraph(work['student']))
    persons_paragraph.append(
        document.add_paragraph('Зачет.кн. №{}'.format(work['number'])))
    persons_paragraph.append(document.add_paragraph('Проверил:'))

    persons_paragraph.append(
        document.add_paragraph(common_info['teacher_duty']))
    persons_paragraph.append(document.add_paragraph(common_info['teacher']))
    document.add_paragraph()
    document.add_paragraph()
    year_par = document.add_paragraph('Саратов {}'.format(common_info['year']))
    document.add_page_break()

    # font = document.styles['Normal'].font
    # font.name = 'Times New Roman'
    # font.size = Pt(14)
    # <editor-fold desc="Alignment settings">
    for par in caption_paragraphs + topic_paragraphs:
        par.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
    for par in persons_paragraph:
        par.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.RIGHT

    year_par.paragraph_format.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
    # </editor-fold>

    document_name = '{number}_{group}_{year}_{work_type}_1.docx'.format(**work)
    return document_name, document