Ejemplo n.º 1
0
    def commit(self):
        if not editor.is_current_file_modified():
            return

        editor.save_current_file()

        entry = self.get_entry(editor.get_current_file_path())

        ash.upload_review(
            self._review_url,
            editor.get_current_file_path(),
            entry.get_name_in_review(),
            entry.get_origin_path()
        )

        ash.get_review_into_file(
            self._review_url,
            entry.get_name_in_review(),
            entry.get_file_path(),
        )

        self._save_origin(entry.get_file_path())

        editor.reopen_current_file()
        editor.redraw()
Ejemplo n.º 2
0
def load_from_url(url, file_name=None):
    active_review = review.Review(url)
    if file_name is not None:
        entry = active_review._add_loaded_file(file_name)

        shutil.copy(editor.get_current_file_path(), entry.get_file_path())

    active_review.load()

    if file_name is not None:
        editor.open_file(entry.get_file_path())

    return active_review
Ejemplo n.º 3
0
    def _save_origin(self, source=None):
        entry = self.get_entry(editor.get_current_file_path())

        origin_path = entry.get_origin_path()
        if not source and os.path.exists(origin_path):
            return

        if source is None:
            source = entry.get_file_path()

        utils.create_file_directories(origin_path)

        shutil.copyfile(source, origin_path)
Ejemplo n.º 4
0
def load_from_current_file():
    with open(editor.get_current_file_path(), 'r') as buffer:
        for line in buffer.readlines():
            modeline = utils.parse_modeline(line)
            if modeline:
                break

    file_name = None
    if 'overview' in modeline:
        file_name = review.OVERVIEW
    if 'file' in modeline:
        file_name = modeline['file']

    return load_from_url(modeline['review-url'], file_name)
Ejemplo n.º 5
0
 def load_current_buffer_from_remote(self):
     self.update_file(editor.get_current_file_path(), force=True)
     editor.reopen_current_file()
Ejemplo n.º 6
0
 def update_current_buffer(self):
     self.update_file(editor.get_current_file_path())