agitprop module

class lib.agitprop.AgitProp(event: caldav.objects.Event)

Bases: object

Extends the functionality of a caldav Event with relevant information needed for a social media post.

Parameters

event (caldav.objects.Event) – The original caldav Event to be initialized as AgitProp.

conf

psmt configuration file

Type

config.Config

verified

If the AgitProp passes all verification checks. Will not allow posting to social media if otherwise.

Type

bool

path

Absolute path to the directory containing the post graphic/caption.

Type

Path

event
Type

caldav.objects.Event

content

The type of post, most commonly ‘anniversary’ or ‘campaign’.

Type

str

caption

Post caption split out by language, with hashtags seperate.

Type

dict[str, list[str]]

graphic

Collection of all saved graphics for the post.

Type

list[Path]

bundle

Collection of both graphics/captions organized by language.

Type

defaultdict[str, Union[list, defaultdict[str, list]]]

start_date
Type

dt.datetime

end_date
Type

dt.datetime

summary

The Event title.

Type

str

description

Event description.

Type

str

dir

Each line in the Event description gets turned into an attribute e.g. the needed ‘dir’ line lists the directory name of where the post graphics are saved.

Type

str

_bundle() None

Further organizes the post data by combining the captions/graphics into one collection, again ordered by language.

_parse_event(event: caldav.objects.Event) Optional[caldav.objects.Event]

Pulls the needed information from the Event object.

Parameters

event (caldav.objects.Event) –

Returns

event – Returned unmodified to be set as an attribute.

Return type

caldav.objects.Event

_verify_caption(caption: list[str]) None

Initial caption verification prior prior to posting to social media.

Reads through the caption file, verifies the languages, and splits each paragraph into lists. It will then call a social method to verify length for the platforms.

Sets the caption attribute and modifies the verified attribute.

Parameters

caption (list) – The FILE.readlines()

Raises

CaptionValidationError

_verify_dir_date() None

Verifies whether the date on the dir attribute saved in the Event description matches the event and sets the date attributes.

description: str
dir: str
end_date: datetime.date
post_all() None

Posts the graphic and caption to all of the approved social media platforms.

post_facebook() None

Logic chain of social methods to post self to Twitter.

post_instagram() None

Logic chain of social methods to post self to Twitter.

post_twitter() None

Logic chain of social methods to post self to Twitter.

start_date: datetime.date
summary: str
class lib.agitprop.Calendar(name: str)

Bases: caldav.objects.Calendar

Builds on the caldav.objects.Calendar class in order to include an easy to use method to pull today’s event.

Parameters

name (str) – The name of the calendar on the caldav server.

end_date

alias of datetime.date

Searches for calendar events given the date range, returning the instantiated AgitProp for the event.

Parameters
  • start (dt.date) –

  • end (dt.date) –

Returns

Collection of AgitProp events.

Return type

list[AgitProp]

start_date

alias of datetime.date

summary

alias of str

today() list[lib.agitprop.AgitProp]

Lazy function identital to event_search but takes no date range and only searches for posts on today’s date.

Returns

Collection of AgitProp events.

Return type

list[AgitProp]

lib.agitprop.get_posts(date: str = '') list[lib.agitprop.AgitProp]

Helper function to quicken post searches for the SMC calendar without having to manually initialize Calendar or AgitProp.

Parameters

date (str) – Formatted as %Y-%m-%d

Returns

Collection of AgitProp events.

Return type

list[AgitProp]