Skip to content

Commit

Permalink
Lint, style
Browse files Browse the repository at this point in the history
ollow flake8, pylint, pymy and other lint, style python code.

Issue 811
  • Loading branch information
timmy61109 committed Dec 16, 2020
1 parent 285a0c9 commit a009a5b
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 27 deletions.
10 changes: 5 additions & 5 deletions examples/config.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/python
# Read the config file for a git repository.
#
# Example usage:
# python examples/config.py
"""Read the config file for a git repository.
Example usage:
python examples/config.py
"""

from dulwich.repo import Repo

Expand Down
32 changes: 19 additions & 13 deletions examples/diff.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
#!/usr/bin/python
# This trivial script demonstrates how to extract the unified diff for a single
# commit in a local repository.
#
# Example usage:
# python examples/diff.py
"""Diff.
This trivial script demonstrates how to extract the unified diff for a single
commit in a local repository.
Example usage:
python examples/diff.py
"""

import sys

from dulwich.repo import Repo

from dulwich.patch import write_tree_diff
import sys

repo_path = "."
commit_id = b"a6602654997420bcfd0bee2a0563d9416afe34b4"

r = Repo(repo_path)
REPO_PATH = "."
COMMIT_ID = b"a6602654997420bcfd0bee2a0563d9416afe34b4"

REPOSITORY = Repo(REPO_PATH)

commit = r[commit_id]
parent_commit = r[commit.parents[0]]
commit = REPOSITORY[COMMIT_ID]
parent_commit = REPOSITORY[commit.parents[0]]
outstream = getattr(sys.stdout, 'buffer', sys.stdout)
write_tree_diff(outstream, r.object_store, parent_commit.tree, commit.tree)
write_tree_diff(
outstream, REPOSITORY.object_store, parent_commit.tree, commit.tree)
5 changes: 3 additions & 2 deletions examples/latest_change.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/python
# Example printing the last author of a specified file
"""Example printing the last author of a specified file."""

import sys

import time

from dulwich.repo import Repo

if len(sys.argv) < 2:
Expand Down
19 changes: 12 additions & 7 deletions examples/memoryrepo.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,28 @@
#!/usr/bin/python
# This script creates a clone of a remote repository in local memory,
# then adds a single file and pushes the result back.
#
# Example usage:
# python examples/memoryrepo.py git+ssh://github.com/jelmer/testrepo
"""Menoryrepo.
This script creates a clone of a remote repository in local memory,
then adds a single file and pushes the result back.
Example usage:
python examples/memoryrepo.py git+ssh://github.com/jelmer/testrepo
"""

import stat

import sys

from dulwich import porcelain

from dulwich.objects import Blob

from dulwich.repo import MemoryRepo

local_repo = MemoryRepo()
local_repo.refs.set_symbolic_ref(b'HEAD', b'refs/heads/master')
print(local_repo.refs.as_dict())

porcelain.fetch(local_repo, sys.argv[1])
local_repo['refs/heads/master'] = local_repo['refs/remotes/origin/master']
local_repo[b'refs/heads/master'] = local_repo[b'refs/remotes/origin/master']

last_tree = local_repo[local_repo['HEAD'].tree]
new_blob = Blob.from_string(b'Some contents')
Expand Down

0 comments on commit a009a5b

Please sign in to comment.