CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-feedgen

Python library for generating web feeds in both ATOM and RSS formats with extensible support for specialized feed formats

Pending
Overview
Eval results
Files

entry-management.mddocs/

Entry Management

Functionality for creating, managing, and configuring individual feed entries with their metadata, content, and links.

Capabilities

FeedEntry Class

Represents individual entries/items within a feed.

class FeedEntry:
    def atom_entry(self, extensions=True):
        """
        Generate ATOM entry XML element.
        
        Args:
            extensions (bool): Include loaded extensions
            
        Returns:
            lxml.etree._Element: ATOM entry element
        """
    
    def rss_entry(self, extensions=True):
        """
        Generate RSS item XML element.
        
        Args:
            extensions (bool): Include loaded extensions
            
        Returns:
            lxml.etree._Element: RSS item element
        """

Entry Creation and Management

Methods for creating and managing entries within feeds.

def add_entry(self, feedEntry=None, order='prepend'):
    """
    Add new entry to feed.
    
    Args:
        feedEntry (FeedEntry, optional): Existing FeedEntry instance
        order (str): 'prepend' or 'append' for entry ordering
        
    Returns:
        FeedEntry: The added entry instance
    """

def add_item(self, item=None):
    """
    Alias for add_entry().
    
    Args:
        item (FeedEntry, optional): Existing FeedEntry instance
        
    Returns:
        FeedEntry: The added entry instance
    """

def remove_entry(self, entry):
    """
    Remove entry from feed.
    
    Args:
        entry (FeedEntry): Entry instance to remove
    """

def remove_item(self, item):
    """
    Alias for remove_entry().
    
    Args:
        item (FeedEntry): Entry instance to remove
    """

def entry(self, entry=None, replace=False):
    """
    Set or get feed entries.
    
    Args:
        entry (list, optional): List of FeedEntry instances
        replace (bool): Replace all entries instead of extending
        
    Returns:
        list: Current entries if no argument provided
    """

Entry Metadata

Core metadata methods for individual entries.

def title(self, title=None):
    """
    Set or get entry title.
    
    Args:
        title (str, optional): Entry title
        
    Returns:
        str or None: Current title if no argument provided
    """

def id(self, id=None):
    """
    Set or get entry ID.
    
    Args:
        id (str, optional): Unique entry identifier URL
        
    Returns:
        str or None: Current ID if no argument provided
    """

def guid(self, guid=None, permalink=False):
    """
    Set or get RSS GUID.
    
    Args:
        guid (str, optional): Globally unique identifier
        permalink (bool): Whether GUID is a permalink
        
    Returns:
        dict or None: Current GUID info if no argument provided
    """

Entry Content

Methods for managing entry content and descriptions.

def content(self, content=None, src=None, type=None):
    """
    Set or get entry content.
    
    Args:
        content (str, optional): Entry content body
        src (str, optional): External content source URL
        type (str, optional): Content MIME type
        
    Returns:
        dict or None: Current content info if no argument provided
    """

def summary(self, summary=None, type=None):
    """
    Set or get entry summary.
    
    Args:
        summary (str, optional): Entry summary text
        type (str, optional): Summary content type
        
    Returns:
        dict or None: Current summary info if no argument provided
    """

def description(self, description=None, isSummary=False):
    """
    Set or get RSS description.
    
    Args:
        description (str, optional): Entry description
        isSummary (bool): Whether description is summary-only
        
    Returns:
        str or None: Current description if no argument provided
    """

Entry Links and Media

Manage entry links, enclosures, and media attachments.

def link(self, link=None, replace=False, **kwargs):
    """
    Set or get entry links.
    
    Args:
        link (dict or list, optional): Link information
        replace (bool): Replace existing links instead of appending
        **kwargs: Link fields as keyword arguments
        
    Returns:
        list: Current links if no argument provided
    """

def enclosure(self, url=None, length=None, type=None):
    """
    Set or get RSS enclosure (media attachment).
    
    Args:
        url (str, optional): Enclosure URL
        length (str, optional): File size in bytes
        type (str, optional): MIME type
        
    Returns:
        dict or None: Current enclosure info if no argument provided
    """

def comments(self, comments=None):
    """
    Set or get entry comments URL.
    
    Args:
        comments (str, optional): Comments page URL
        
    Returns:
        str or None: Current comments URL if no argument provided
    """

Entry Timestamps

Manage entry publication and update timestamps.

def updated(self, updated=None):
    """
    Set or get entry updated timestamp.
    
    Args:
        updated (datetime or str, optional): Last updated timestamp
        
    Returns:
        datetime or None: Current updated timestamp if no argument provided
    """

def published(self, published=None):
    """
    Set or get entry published timestamp.
    
    Args:
        published (datetime or str, optional): Publication timestamp
        
    Returns:
        datetime or None: Current published timestamp if no argument provided
    """

def pubDate(self, pubDate=None):
    """
    Set or get RSS publication date.
    
    Args:
        pubDate (datetime or str, optional): Publication timestamp
        
    Returns:
        datetime or None: Current pubDate if no argument provided
    """

def pubdate(self, pubDate=None):
    """
    Deprecated alias for pubDate(). Use published() or pubDate() instead.
    
    Args:
        pubDate (datetime or str, optional): Publication timestamp
        
    Returns:
        datetime or None: Current pubDate if no argument provided
        
    Note:
        This method is deprecated and may be removed in feedgen ≥ 0.8
    """

Entry Authors and Contributors

Manage entry-level author and contributor information.

def author(self, author=None, replace=False, **kwargs):
    """
    Set or get entry author(s).
    
    Args:
        author (dict or list, optional): Author information
        replace (bool): Replace existing authors instead of appending
        **kwargs: Author fields as keyword arguments
        
    Returns:
        list: Current authors if no argument provided
    """

def contributor(self, contributor=None, replace=False, **kwargs):
    """
    Set or get entry contributor(s).
    
    Args:
        contributor (dict or list, optional): Contributor information
        replace (bool): Replace existing contributors instead of appending
        **kwargs: Contributor fields as keyword arguments
        
    Returns:
        list: Current contributors if no argument provided
    """

Entry Categories and Classification

Organize entries with categories and tags.

def category(self, category=None, replace=False, **kwargs):
    """
    Set or get entry categories.
    
    Args:
        category (dict or list, optional): Category information
        replace (bool): Replace existing categories instead of appending
        **kwargs: Category fields as keyword arguments
        
    Returns:
        list: Current categories if no argument provided
    """

Additional Entry Metadata

Other entry-specific metadata fields.

def rights(self, rights=None):
    """
    Set or get entry rights/copyright.
    
    Args:
        rights (str, optional): Rights/copyright statement
        
    Returns:
        str or None: Current rights if no argument provided
    """

def source(self, url=None, title=None):
    """
    Set or get entry source information.
    
    Args:
        url (str, optional): Source URL
        title (str, optional): Source title
        
    Returns:
        dict or None: Current source info if no argument provided
    """

def ttl(self, ttl=None):
    """
    Set or get entry time-to-live.
    
    Args:
        ttl (int, optional): TTL in minutes
        
    Returns:
        int or None: Current TTL if no argument provided
    """

Usage Examples

Creating and Managing Entries

from feedgen.feed import FeedGenerator

fg = FeedGenerator()
# ... set up feed metadata ...

# Add new entries
entry1 = fg.add_entry()
entry2 = fg.add_entry(order='append')  # Add to end instead of beginning

# Remove entries
fg.remove_entry(entry1)

# Get all entries
all_entries = fg.entry()
print(f"Feed has {len(all_entries)} entries")

Basic Entry Setup

# Create entry with required metadata
fe = fg.add_entry()
fe.id('http://example.com/posts/first-post')
fe.title('My First Blog Post')
fe.description('This is my first blog post about Python programming')

# Set publication timestamp
from datetime import datetime
import dateutil.tz
fe.published(datetime.now(dateutil.tz.tzutc()))

# Add link to full article
fe.link(href='http://example.com/posts/first-post', rel='alternate')

Rich Content Entries

# Entry with HTML content
fe.content("""
<p>This is a <strong>rich HTML</strong> blog post with formatting.</p>
<ul>
    <li>Lists</li>
    <li>Links: <a href="http://example.com">Example</a></li>
    <li>Code: <code>print("Hello World")</code></li>
</ul>
""", type='html')

# Entry with external content
fe.content(src='http://example.com/posts/full-content.html', type='html')

# Summary for RSS readers
fe.summary('A brief summary of the full post content...')

Media and Attachments

# Add media enclosure (podcast, video, etc.)
fe.enclosure(
    url='http://example.com/podcast/episode001.mp3',
    length='15360000',  # Size in bytes
    type='audio/mpeg'
)

# Comments link
fe.comments('http://example.com/posts/first-post#comments')

# Source attribution
fe.source(
    url='http://originalblog.example.com/feed',
    title='Original Blog'
)

Entry Categorization

# Add categories/tags
fe.category(term='python', label='Python Programming')
fe.category([
    {'term': 'web-development', 'label': 'Web Development'},
    {'term': 'tutorial', 'label': 'Tutorial'}
])

# Entry-specific author (different from feed author)
fe.author({
    'name': 'Guest Author',
    'email': 'guest@example.com'
})

Install with Tessl CLI

npx tessl i tessl/pypi-feedgen

docs

entry-management.md

extensions.md

feed-generation.md

feed-metadata.md

index.md

tile.json