Passim.Item

g GObject.Object GObject.Object Passim.Item Passim.Item GObject.Object->Passim.Item

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

flag_from_string (item_flag)

class

flag_to_string (item_flag)

class

from_variant (value)

class

new ()

add_flag (flag)

get_age ()

get_basename ()

get_bytes ()

get_cmdline ()

get_ctime ()

get_file ()

get_flags ()

get_flags_as_string ()

get_hash ()

get_max_age ()

get_share_count ()

get_share_limit ()

get_size ()

get_stream ()

has_flag (flag)

load_filename (filename)

remove_flag (flag)

set_basename (basename)

set_bytes (bytes)

set_cmdline (cmdline)

set_ctime (ctime)

set_file (file)

set_flags (flags)

set_hash (hash)

set_max_age (max_age)

set_share_count (share_count)

set_share_limit (share_limit)

set_size (size)

set_stream (stream)

to_string ()

to_variant ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent_instance

GObject.Object

r

Class Details

class Passim.Item(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Passim.ItemClass

A shared item.

classmethod flag_from_string(item_flag)
Parameters:

item_flag (str or None) – a string, e.g. next-reboot

Returns:

enumerated value

Return type:

int

Converts a string to an enumerated item flag.

New in version 0.1.0.

classmethod flag_to_string(item_flag)
Parameters:

item_flag (int) – item flags, e.g. Passim.ITEM_FLAG_NEXT_REBOOT

Returns:

identifier string

Return type:

str

Converts an enumerated item flag to a string.

New in version 0.1.0.

classmethod from_variant(value)
Parameters:

value (GLib.Variant) – the serialized data

Returns:

a new Passim.Item, or None if value was invalid

Return type:

Passim.Item

Creates a new item using serialized data.

New in version 0.1.0.

classmethod new()
Returns:

a new Passim.Item

Return type:

Passim.Item

Creates a new item.

New in version 0.1.0.

add_flag(flag)
Parameters:

flag (int) – the #PassimItemFlags

Adds a specific item flag to the item.

New in version 0.1.0.

get_age()
Returns:

time in seconds, or 0 for invalid.

Return type:

int

Gets the current file age.

New in version 0.1.0.

get_basename()
Returns:

the test basename, or None if unset

Return type:

str

Gets the basename of the file that was published.

New in version 0.1.0.

get_bytes()
Returns:

a GLib.Bytes, or None if unset

Return type:

GLib.Bytes

Gets the local bytes in the cache.

New in version 0.1.0.

get_cmdline()
Returns:

the binary name, or None if unset

Return type:

str

Gets the cmdline of the binary that published the item.

New in version 0.1.0.

get_ctime()
Returns:

the creation time, or None if unset

Return type:

GLib.DateTime

Gets the creation time of the file.

New in version 0.1.0.

get_file()
Returns:

a Gio.File, or None if unset

Return type:

Gio.File

Gets the local file in the cache.

New in version 0.1.0.

get_flags()
Returns:

item flags, or 0 if unset

Return type:

int

Gets the item flags.

New in version 0.1.0.

get_flags_as_string()
Returns:

string

Return type:

str

Gets the item flags.

New in version 0.1.0.

get_hash()
Returns:

the typically in SHA-256 lowercase form, or None if unset

Return type:

str

Gets the file hash.

New in version 0.1.0.

get_max_age()
Returns:

time in seconds

Return type:

int

Gets the maximum permitted file age.

New in version 0.1.0.

get_share_count()
Returns:

the count, or 0 if unset

Return type:

int

Gets the current number of times the item has been shared to other machines.

New in version 0.1.0.

get_share_limit()
Returns:

share limit, or 0 if unset

Return type:

int

Gets the maximum number of times that the file can be shared.

New in version 0.1.0.

get_size()
Returns:

share limit, or 0 if unset

Return type:

int

Gets the size of the file in bytes.

New in version 0.1.2.

get_stream()
Returns:

a Gio.InputStream, or None if unset

Return type:

Gio.InputStream

Gets the input stream for the item.

New in version 0.1.5.

has_flag(flag)
Parameters:

flag (int) – a item flag

Returns:

True if the flag is set

Return type:

bool

Finds if the item has a specific item flag.

New in version 0.1.0.

load_filename(filename)
Parameters:

filename (str) – a filename with full path

Raises:

GLib.Error

Return type:

bool

Loads the item from a file on disk.

New in version 0.1.0.

remove_flag(flag)
Parameters:

flag (int) – a item flag

Removes a specific item flag from the item.

New in version 0.1.0.

set_basename(basename)
Parameters:

basename (str or None) – the basename name

Sets the basename of the file that was published.

New in version 0.1.0.

set_bytes(bytes)
Parameters:

bytes (GLib.Bytes or None) – a GLib.Bytes

Sets the local bytes in the cache.

New in version 0.1.0.

set_cmdline(cmdline)
Parameters:

cmdline (str or None) – the binary name

Sets the cmdline of the binary that published the item.

NOTE: this is desgined as a hint, and should not be used for security. The command line is obtained via /proc/<pid>/cmdline and it may be possible to falsify the data by a malicious binary running as root under certain conditions.

New in version 0.1.0.

set_ctime(ctime)
Parameters:

ctime (GLib.DateTime or None) – a GLib.DateTime

Sets the creation time of the file.

New in version 0.1.0.

set_file(file)
Parameters:

file (Gio.File or None) – a Gio.File

Sets the local file in the cache.

New in version 0.1.0.

set_flags(flags)
Parameters:

flags (int) – item flags, e.g. Passim.ITEM_FLAG_NEXT_REBOOT

Sets the item flags.

New in version 0.1.0.

set_hash(hash)
Parameters:

hash (str or None) – the hash, typically in SHA-256 lowercase form

Sets the file hash.

New in version 0.1.0.

set_max_age(max_age)
Parameters:

max_age (int) – time in seconds

Sets the maximum permitted file age.

New in version 0.1.0.

set_share_count(share_count)
Parameters:

share_count (int) – the count, or 0 to unset

Sets the current number of times the item has been shared to other machines.

New in version 0.1.0.

set_share_limit(share_limit)
Parameters:

share_limit (int) – the share limit, or 0

Sets the maximum number of times that the file can be shared.

New in version 0.1.0.

set_size(size)
Parameters:

size (int) – the share limit, or 0

Sets the size of the file in bytes.

New in version 0.1.2.

set_stream(stream)
Parameters:

stream (Gio.InputStream or None) – a Gio.InputStream

Sets the input stream stream for the item.

NOTE: This *MUST* be a #GUnixInputStream, or subclass thereof.

New in version 0.1.5.

to_string()
Returns:

text, or None for invalid

Return type:

str

Builds a text representation of the object.

New in version 0.1.0.

to_variant()
Returns:

the serialized data, or None for error

Return type:

GLib.Variant

Serialize the item data.

New in version 0.1.0.