Example #1
0
 def user_process_info(pid):
     if pid not in user_processes_by_pid:
         return None
     user_process = user_processes_by_pid[pid]
     return select_attrs(
         user_process,
         "user_id time_since_last_used awaiting_input fresh_process history",
     )
Example #2
0
File: db.py Project: ttamg/birdseye
 def basic_dict(call):
     return dict(
         arguments=call.arguments_list,
         **select_attrs(
             call,
             "id function_id return_value traceback "
             "exception start_time",
         ),
     )
Example #3
0
 def current_state(self):
     return dict(
         **select_attrs(self, "hints step_index"),
         page_index=self.page.index,
         showEditor=self.page.index >= WritingPrograms.index,
         showSnoop=(self.page.index, self.step_index) >= (UnderstandingProgramsWithSnoop.index, 1),
         showPythonTutor=self.page.index >= UnderstandingProgramsWithPythonTutor.index,
         showBirdseye=True,
     )
Example #4
0
def get_pages():
    return dict(
        pages={
            slug: dict(
                **select_attrs(page, "slug title index step_names"),
                steps=page.step_dicts,
            )
            for slug, page in pages.items()
        },
        pageSlugsList=page_slugs_list,
    )
Example #5
0
    def load_data(self):
        user = self.user
        if user.is_anonymous:
            return {}

        return dict(
            pages=[
                select_attrs(page, "title step_texts")
                for page in pages.values()
            ],
            state=self.current_state(),
            user=dict(
                email=user.email,
                developerMode=user.developer_mode,
            ),
        )
Example #6
0
def load_chapters():
    chapters_dir = Path(__file__).parent / "chapters"
    path: Path
    for path in sorted(chapters_dir.glob("c*.py")):
        module_name = path.stem
        full_module_name = "core.chapters." + module_name
        import_module(full_module_name)
        slug = module_name[4:]
        title = slug.replace("_", " ").title()
        title = t.get(t.chapter_title(slug), title)
        chapter_pages = [
            select_attrs(page, "title slug")
            for page in pages.values()
            if page.__module__ == full_module_name
        ]
        yield dict(slug=slug, title=title, pages=chapter_pages)
Example #7
0
    def load_data(self):
        user = self.user
        if user.is_anonymous:
            return {}

        return dict(
            pages=[
                dict(**select_attrs(page, "slug title index"), steps=page.step_dicts)
                for page in pages.values()
            ],
            state=self.current_state(),
            user=dict(
                email=user.email,
                developerMode=user.developer_mode,
            ),
            page_index=pages[self.user.page_slug].index,
        )
Example #8
0
 def basic_dict(func):
     return select_attrs(func,
                         'file name lineno hash body_hash type')