CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-github3--py

Python wrapper for the GitHub API(http://developer.github.com/v3)

Pending
Overview
Eval results
Files

repositories.mddocs/

Repository Operations

Comprehensive repository management including creation, modification, collaboration, and content operations for both authenticated and public repositories. This covers the full repository lifecycle from creation to archival.

Capabilities

Repository Retrieval

Access repositories by various identifiers and list repositories with flexible filtering options.

def repository(self, owner, repository):
    """
    Retrieve a specific repository.
    
    Parameters:
    - owner (str, required): Repository owner username or organization
    - repository (str, required): Repository name
    
    Returns:
    Repository object with full details or None if not found
    """

def repository_with_id(self, number):
    """
    Retrieve repository using its unique GitHub ID.
    
    Parameters:
    - number (int, required): Repository's unique GitHub ID
    
    Returns:
    Repository object or None if not found
    """

def repositories(self, type=None, sort=None, direction=None, number=-1, etag=None):
    """
    List repositories for the authenticated user.
    
    Parameters:
    - type (str, optional): 'all', 'owner', 'public', 'private', 'member'
    - sort (str, optional): 'created', 'updated', 'pushed', 'full_name'
    - direction (str, optional): 'asc' or 'desc'
    - number (int): Number to return (-1 for all)
    - etag (str, optional): ETag from previous request
    
    Returns:
    Generator of ShortRepository objects
    """

def repositories_by(self, username, type=None, sort=None, direction=None, number=-1, etag=None):
    """
    List public repositories for a specific user.
    
    Parameters:
    - username (str, required): Target user's username
    - type (str, optional): 'all', 'owner', 'member'
    - sort (str, optional): 'created', 'updated', 'pushed', 'full_name'
    - direction (str, optional): 'asc' or 'desc'
    - number (int): Number to return (-1 for all)
    - etag (str, optional): ETag from previous request
    
    Returns:
    Generator of ShortRepository objects
    """

def all_repositories(self, number=-1, since=None, etag=None, per_page=None):
    """
    Iterate over every public repository in creation order.
    
    Parameters:
    - number (int): Number to return (-1 for all)
    - since (int, optional): Last repository ID seen for pagination
    - etag (str, optional): ETag from previous request
    - per_page (int, optional): Results per page
    
    Returns:
    Generator of ShortRepository objects
    """

Usage Examples

# Get specific repository
repo = gh.repository('octocat', 'Hello-World')
print(f"Repository: {repo.full_name}")
print(f"Description: {repo.description}")
print(f"Stars: {repo.stargazers_count}")

# Get repository by ID
repo = gh.repository_with_id(1296269)

# List authenticated user's repositories
for repo in gh.repositories(type='owner', sort='updated'):
    print(f"{repo.full_name} - {repo.updated_at}")

# List another user's repositories
for repo in gh.repositories_by('octocat', sort='created'):
    print(f"{repo.name} - Created: {repo.created_at}")

# Browse all public repositories
for repo in gh.all_repositories(number=100):
    print(f"{repo.full_name} - ID: {repo.id}")

Repository Creation

Create new repositories with comprehensive configuration options for both personal and organizational use.

def create_repository(self, name, description="", homepage="", private=False, has_issues=True, has_wiki=True, auto_init=False, gitignore_template="", has_projects=True):
    """
    Create a repository for the authenticated user.
    
    Parameters:
    - name (str, required): Repository name (max 100 characters)
    - description (str, optional): Repository description
    - homepage (str, optional): Homepage URL
    - private (bool): Create as private repository (default: False)
    - has_issues (bool): Enable issues (default: True)
    - has_wiki (bool): Enable wiki (default: True)
    - auto_init (bool): Initialize with README (default: False)
    - gitignore_template (str, optional): Gitignore template name
    - has_projects (bool): Enable projects (default: True)
    
    Returns:
    Repository object for the created repository
    """

Usage Examples

# Create basic repository
repo = gh.create_repository('my-new-project')

# Create repository with full configuration
repo = gh.create_repository(
    name='advanced-project',
    description='A comprehensive project with all features',
    homepage='https://myproject.com',
    private=True,
    has_issues=True,
    has_wiki=True,
    auto_init=True,
    gitignore_template='Python',
    has_projects=True
)

print(f"Created repository: {repo.html_url}")

Repository Starring

Manage repository stars for bookmarking and discovery of interesting projects.

def star(self, username, repo):
    """
    Star a repository.
    
    Parameters:
    - username (str, required): Repository owner
    - repo (str, required): Repository name
    
    Returns:
    bool: True if successful, False otherwise
    """

def unstar(self, username, repo):
    """
    Remove star from a repository.
    
    Parameters:
    - username (str, required): Repository owner
    - repo (str, required): Repository name
    
    Returns:
    bool: True if successful, False otherwise
    """

def is_starred(self, username, repo):
    """
    Check if the authenticated user has starred a repository.
    
    Parameters:
    - username (str, required): Repository owner
    - repo (str, required): Repository name
    
    Returns:
    bool: True if starred, False otherwise
    """

def starred(self, sort=None, direction=None, number=-1, etag=None):
    """
    Iterate over repositories starred by the authenticated user.
    
    Parameters:
    - sort (str, optional): 'created' or 'updated'
    - direction (str, optional): 'asc' or 'desc'
    - number (int): Number to return (-1 for all)
    - etag (str, optional): ETag from previous request
    
    Returns:
    Generator of ShortRepository objects
    """

def starred_by(self, username, sort=None, direction=None, number=-1, etag=None):
    """
    Iterate over repositories starred by a specific user.
    
    Parameters:
    - username (str, required): Target user's username
    - sort (str, optional): 'created' or 'updated'
    - direction (str, optional): 'asc' or 'desc'
    - number (int): Number to return (-1 for all)
    - etag (str, optional): ETag from previous request
    
    Returns:
    Generator of ShortRepository objects
    """

Usage Examples

# Star a repository
success = gh.star('octocat', 'Hello-World')
if success:
    print("Repository starred successfully")

# Check if repository is starred
if gh.is_starred('octocat', 'Hello-World'):
    print("Repository is starred")

# List your starred repositories
for repo in gh.starred(sort='updated'):
    print(f"Starred: {repo.full_name}")

# List repositories starred by another user
for repo in gh.starred_by('octocat'):
    print(f"{repo.full_name} - {repo.stargazers_count} stars")

# Unstar a repository
gh.unstar('octocat', 'Hello-World')

Repository Subscriptions

Manage repository watching/subscription status for notifications and activity tracking.

def subscriptions(self, number=-1, etag=None):
    """
    Iterate over repositories subscribed to by the authenticated user.
    
    Parameters:
    - number (int): Number to return (-1 for all)
    - etag (str, optional): ETag from previous request
    
    Returns:
    Generator of ShortRepository objects
    """

def subscriptions_for(self, username, number=-1, etag=None):
    """
    Iterate over repositories subscribed to by a specific user.
    
    Parameters:
    - username (str, required): Target user's username
    - number (int): Number to return (-1 for all)  
    - etag (str, optional): ETag from previous request
    
    Returns:
    Generator of ShortRepository objects
    """

Usage Examples

# List your subscribed repositories
for repo in gh.subscriptions():
    print(f"Subscribed to: {repo.full_name}")

# List repositories another user subscribes to
for repo in gh.subscriptions_for('octocat'):
    print(f"{repo.full_name}")

Repository Invitations

Manage collaboration invitations for repository access and permissions.

def repository_invitations(self, number=-1, etag=None):
    """
    Iterate over repository invitations for the current user.
    
    Parameters:
    - number (int): Number to return (-1 for all)
    - etag (str, optional): ETag from previous request
    
    Returns:
    Generator of Invitation objects
    """

Usage Examples

# List pending repository invitations
for invitation in gh.repository_invitations():
    print(f"Invited to: {invitation.repository.full_name}")
    print(f"Invited by: {invitation.inviter.login}")
    print(f"Permissions: {invitation.permissions}")

Repository Model Classes

class Repository:
    """Full repository representation with all metadata and operations"""
    id: int
    name: str
    full_name: str
    description: str
    private: bool
    fork: bool
    url: str
    html_url: str
    clone_url: str
    ssh_url: str
    size: int
    stargazers_count: int
    watchers_count: int
    forks_count: int
    open_issues_count: int
    language: str
    created_at: datetime
    updated_at: datetime
    pushed_at: datetime
    default_branch: str
    # ... additional repository properties and methods

class ShortRepository:
    """Abbreviated repository representation for list operations"""
    id: int
    name: str
    full_name: str
    private: bool
    # ... essential repository properties

class StarredRepository:
    """Repository with starring timestamp information"""
    starred_at: datetime
    # ... includes all Repository properties

class Invitation:
    """Repository collaboration invitation"""
    id: int
    permissions: str
    created_at: datetime
    inviter: User
    repository: Repository
    # ... additional invitation properties

Common Repository Patterns

Repository Discovery

# Find popular repositories
for repo in gh.search_repositories('language:python stars:>1000').get_iterator():
    print(f"{repo.repository.full_name} - {repo.repository.stargazers_count} stars")

Repository Creation and Setup

# Create and configure new repository
repo = gh.create_repository(
    name='my-project',
    description='My awesome project',
    auto_init=True,
    gitignore_template='Python'
)

# Add topics/tags
repo.replace_topics(['python', 'api', 'github'])

Repository Management

# Get repository details
repo = gh.repository('owner', 'repo-name')

# Check repository properties
if repo.private:
    print("This is a private repository")

if repo.fork:
    print(f"This is a fork of {repo.parent.full_name}")

# Access repository statistics
print(f"Stars: {repo.stargazers_count}")
print(f"Forks: {repo.forks_count}")
print(f"Issues: {repo.open_issues_count}")

Collaboration Management

# List repository contributors
for contributor in repo.contributors():
    print(f"{contributor.login}: {contributor.contributions} contributions")

# List repository collaborators
for collaborator in repo.collaborators():
    print(f"{collaborator.login} - {collaborator.permissions}")

Install with Tessl CLI

npx tessl i tessl/pypi-github3--py

docs

authentication.md

index.md

issues-prs.md

repositories.md

users.md

tile.json