9. Moduli pyArchInit: Classi e Funzioni

Importante

In questa sezione si descivono le funzioni e alcune delle classi presenti in pyarchinit che possano aiutare allo sviluppo e implementazione del codice.

9.1. pyarchinit OS utility

Nota

Questa classe presenta alcune funzioni per copiare immagini, file e creare cartelle durante l’installazione del plugin


class Pyarchinit_OS_Utility[sorgente]

Pyarchinit_OS_Utility

static checkGraphvizInstallation()[sorgente]

Return True if Graphviz is installed

static checkPostgresInstallation()[sorgente]

Return True if Postgres is installed

copy_file(f, d)[sorgente]

Copy file

Parametri:
  • str

    • file path

  • str

    • destination file

create_dir(d)[sorgente]

Create directory

:param str - path directory

static isMac()[sorgente]

Return True if platform is mac

static isWindows()[sorgente]

Return True if platform is Windows

9.2. pyarchinit_utility

Nota

Questa classe presenta funzioni utili per aggiungere elementi ad un dizionario, contare elementi in una lista, cercare liste in un dizionario, indicizzare una colonna in una lista convertire tuple in liste.


class Utility[sorgente]
add_item_to_dict(d, i)[sorgente]

receive a dict and a list containt tuple with key,value and add them to dict

count_list_eq_v(l, v)[sorgente]

take a list and a value. If the number of occurens of a items inside the list is equal to v value, put the singol value into list_res as a list. Return a list of lists

find_list_in_dict(d)[sorgente]

recives a dict and if contains a list of lists and delete the item from the dict. Return a tuple containin the new dict and a list of tuples wich contain the keys and the values

list_col_index_value(v1, v2)[sorgente]

return two lists into one tupla, takin” two list with same lenght and lookin for the occurrences. for every occurrences between v_1 and v_2 the v_2 value it’s charged into mod_value and its position in list it’s put into list_index.

list_tup_2_list(l)[sorgente]

take a list of tuples ad return a list of lists

pos_none_in_list(l)[sorgente]

take a list of values and return the position number of the values equal to “None”

select_in_list(l, p)[sorgente]

take a list of lists or value and return the in a list of lists the value taken by the value of p.

tup_2_list(t, s='', i=0)[sorgente]

take a tuple of strings, and return a list of lists of the values. if s is set, add the value to the strings. If i is set return only the value in the i position

tup_2_list_II(l)[sorgente]

take a list of tuples ad return a list of lists

tup_2_list_III(l)[sorgente]

take a list of tuples ad return a list of values

9.3. pyarchinit installation folder

Nota

Questa classe presenta due funzioni per installare nel percorso del tuo utente i file di configurazione e le cartelle


class pyarchinit_Folder_installation[sorgente]
installConfigFile(path)[sorgente]

Installa la configurazione file

install_dir()[sorgente]

Funzione per installare la directory pyarchinit nel tuo utente

9.4. settings

Nota

Questa classe presenta due funzioni di settaggio


class Settings(s)[sorgente]

Configurazione DataBase

SERVER = «»

HOST = «»

DATABASE = «»

PASSWORD = «»

PORT = «»

USER = «»

THUMB_PATH = «»

THUMB_RESIZE = «»

SITE_SET = «»

LOGO = «»

RESOURCES_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, “resources”)

OS_UTILITY = Pyarchinit_OS_Utility()

HOME = os.environ[“PYARCHINIT_HOME”]

path_rel = os.path.join(os.sep, HOME, “pyarchinit_DB_folder”, “config.cfg”)

conf = open( path_rel, «rb+»)

data = conf.read()

text = (b’THUMB_RESIZE”)

text_a = (b’SITE_SET”)

text_b = (b’LOGO”)

if text in data:

pass

else:

conf.seek(-3, 2) conf.read(1) conf.write(b»”,”THUMB_RESIZE” : “insert path for the image resized”»)

if text_a in data:

pass

else:

conf.seek(-3, 2) conf.read(1) conf.write(b»”,”SITE_SET” : “»)

if text_b in data:

pass

else:

conf.seek(-3, 2) conf.read(1) conf.write(b»”,”LOGO” : “insert path for the image logo”}»)

conf.close()

set_configuration()[sorgente]

Configurazione database

9.5. pyarchinit US-USM

Nota

mettere descrizione


class pyarchinit_US[sorgente]
EM_extract_node_name(node_element)[sorgente]

Initialize variables to store node information

check_if_empty(name)[sorgente]

This is a function that checks if a name is empty If it is empty, it returns «–None–» If it is not empty, it returns the name

on_pushButton_csv2us_pressed()[sorgente]

This function is responsible for importing data from a CSV file into the “us_table” of the SQLite database. When the “csv2us” button is pressed, the user is prompted to select a CSV file with the «Set file name» dialog. The selected file is then opened and read, with the data from the file being inserted into the “us_table” of the SQLite database. The function starts by defining the path of the SQLite database, using the self.HOME variable and os.sep. Then it opens a QFileDialog to select a CSV file and assigns the file path to the variable “filename”. It then creates an instance of the “Connection” class and uses it to get the name of the SQLite database. It creates a connection to the SQLite database using the connect method and assigns it to the “con” variable. A cursor object is created using the “con.cursor()” method and assigned to the “cur” variable. It opens the selected CSV file in read mode, and uses the “csv.DictReader” class to read the file and convert it into a dictionary object. It then creates a list of tuples, each containing the values for the “site”, “area”, “us”, “unit_type” and “i_stratigrafica” columns. It then uses the “executemany” method of the cursor to insert the data from the list of tuples into the “us_table” of the SQLite database. The “commit” method is used to save the changes to the database. In case of any AssertionError, a warning message is displayed using the QMessageBox.warning method. Otherwise, a message saying “done” is displayed using the QMessageBox.information method. Finally, the connection to the database is closed using the “con.close()” method.

on_pushButton_fix_pressed()[sorgente]

This function is called when the user press the fix button. It will first get the current text in comboBox_sito and comboBox_area widgets, and create a search_dict dictionary with “sito”: sito and “area”: area as key-value pairs. Then it queries the database with the search_dict and the MAPPER_TABLE_CLASS and assigns the result to the variable «records» After that, it iterates over the range of the length of «records» and sets the checkBox_validation_rapp to be checked, selects each row of the tableWidget_rapporti, calls the check_listoflist() function, sets the progressBar_3 to a value based on the current row number and total number of rows, and updates the GUI. Finally, it resets the progressBar_3 to 0.

on_pushButton_graphml2csv_pressed()[sorgente]

This is a function that is called when a button is pressed This is a QGIS setting

search_rapp()[sorgente]

The function search_rapp is used to search for a specific value in the tableWidget_rapporti. First, it clears the current selection in the tableWidget_rapporti. It checks if the input variable “s” is empty, if it is then the function exits without searching. Then it uses the findItems method to find all items in the tableWidget_rapporti that match the string “1” and stores the matching items in the list matching_items. If there are any matching items, it sets the first item in the matching_items list as the current item in the tableWidget_rapporti.

unit_type_select()[sorgente]

This function creates a dialog box for the user to select a unit type. The available unit types are determined by the value of the variable “L”, which is either “it” or “en”. If “L” is “it”, the available unit types are (“US”,”USM”,”USVA”,”USVB”,”USVC”,”USD”,”CON”,”VSF”,”SF”,”SUS”,”Combinar”,”Extractor”,”DOC”,”property”). If “L” is “en”, the available unit types are (“SU”,”WSU”,”USVA”,”USVB”,”USVC”,”USD”,”CON”,”VSF”,”SF”,”SUS”,”Combinar”,”Extractor”,”DOC”,”property”). The user’s selection is returned as a string.

9.6. pyarchinit db manager

Nota

Questa classe presenta tutte le funzioni di gestione del database


class Pyarchinit_db_management(c)[sorgente]

Nota

This function creates a database manager which creates the database and then creates the database object

Pyarchinit_db_management()
__init__(c)[sorgente]

Initialize the connection to DB. This is called by __init__ and should not be called directly.

param c:

The string containing the connection string. This string is passed to the connect () method of the DBConnection object.

type:

[str]

returns:

True if successful False otherwise. Note that this method does not return anything

rtype:

[boolean]

connection()[sorgente]

Connect to the database and check if it is working. This is called by QGIS when the user clicks the connect button .. py:function:: connection()

returns:

True if the connection is working False if it is

rtype:

[str]

delete_one_record(tn, id_col, id_rec)[sorgente]

Delete a record from a table. This is a wrapper around the sqlalchemy delete_record method .. :noindex: .. py:function:: delete_one_record(self, tn, id_col, id_rec)

param tn:

the name of the table to delete from.

type:

[str]

param id_col:

the name of the id column.

type:

[int]

param id_rec:

the name of the id record.

type:

[int]

returns:

the number of rows deleted or - 1 if an error

rtype:

[int]

delete_thumb_from_db_sql(s)[sorgente]

Delete a Thumb from the database. This is used to delete thumbnails that no longer exist

param s:

the filename of the thumbnail to delete. It must be in the database

returns:

the result of the sql execution. It is a list

dir_query()[sorgente]

Return a generator that yields SQLAlchemy query objects. This is useful for building a directory - based query from an SQLAlchemy table or other data that can be used to retrieve data from the database.

param self:

The class . Engine that is used to create the database.

returns:

A generator that yields SQLAlchemy query objects that can be used to retrieve data

empty_find_check(table_class_str, find_check_value)[sorgente]

Empty the find_check field in the table_class_str. This is used to prevent an error in SQLAlchemy’s create_table ()

param table_class_str:

The name of the table class

param find_check_value:

The value to set the field to

returns:

True if the update was successful False if it wasn’t

execute_sql_create_db()[sorgente]

execute_sql_create_db Execute the SQL create db

execute_sql_create_layers()[sorgente]

execute_sql_create_layers Execute SQL create layer for the SQL

execute_sql_create_spatialite_db()[sorgente]

execute_sql_create_spatialite_db Execute SQL for the SQLite database

fields_list(t, s='')[sorgente]

Returns a list of fields in a table. This is useful for creating table objects that don’t have a table_name or table_name attribute

param t:

The table name to search for fields in.

param s:

The column to search for. If empty all columns are returned.

returns:

A list of field names or a single column name

group_by(tn, fn, CD)[sorgente]

Group rows by a field. This is useful for getting a list of rows that have been grouped by a field and their values

param tn:

The name of the table to query (“users”” groups’etc. )

param fn:

The name of the field to query (“users”” groups’etc. )

param CD:

The class of the table to query (“users”” groups’etc. )

returns:

A list of rows in the form of ( row_name value)

insert_arbitrary_number_of_us_records(us_range, sito, area, n_us, unita_tipo)[sorgente]

Insert a number of US records into the QGIS database. This is a helper function to avoid duplication of data in the database

Parametri:
  • us_range – Number of US records to insert ( int )

  • sito – Site ID ( str ). It’s the same as the ID of the site

  • area – Area ID ( str ). It’s

  • n_us – number us

  • unita_tipo – tupe of SU

insert_data_conflict(data)[sorgente]

Insert data into the database. This is a wrapper around the sessionmaker’s begin_nested () method to ensure that the transaction is commited before returning.

param data:

The data to insert. It is a dictionary with key / value pairs that are used as keys and values as values.

returns:

True if the data was inserted False otherwise. Note that this will return False if the data already exists

insert_data_session(data)[sorgente]

Inserts data into database. This is a convenience method for inserting data into database.

param data:

Data to insert into database. The format is described in : meth : sqlalchemy. orm. orm. BaseModel. add .

returns:

True if insertion was successful False otherwise. >>> from sqlalchemy import BaseModel >>> db = BaseModel (“SELECT * FROM ` test_data ` WHERE id = 1 “

insert_media2entity_values(*arg)[sorgente]

Inserts the values into the layer mediatoentity_table ..py:function:: self.Pyarchinit_db_management().insert_media2entity_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_media2entity_view_values(*arg)[sorgente]

Inserts the values into the layer mediatoentity_view ..py:function:: self.Pyarchinit_db_management().insert_media2entity_view_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_media_values(*arg)[sorgente]

Inserts the values into the layer media_table ..py:function:: self.Pyarchinit_db_management().insert_media_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_mediathumb_values(*arg)[sorgente]

Inserts the values into the layer mediathumb_table ..py:function:: self.Pyarchinit_db_management().insert_mediathumb_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pdf_administrator_values(*arg)[sorgente]

Inserts the values into the layer pdf_administrator ..py:function:: self.Pyarchinit_db_management().insert_pdf_administrator_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_periodizzazione_values(*arg)[sorgente]

Inserts the values into the layer periodizzazione_table ..py:function:: self.Pyarchinit_db_management().insert_periodizzazione_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pottery_values(*arg)[sorgente]

Inserts the values into the dictionary pottery_table ..py:function:: self.Pyarchinit_db_management().insert_pottery_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pycampioni(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_campionature ..py:function:: self.Pyarchinit_db_management().insert_pycampioni(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pydocumentazione(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_documentazione ..py:function:: self.Pyarchinit_db_management().insert_pydocumentazione(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyindividui(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_individui ..py:function:: self.Pyarchinit_db_management().insert_pyindividui(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pylineeriferimento(*arg)[sorgente]

Inserts the values into the layer pyarchinit_linee_rif ..py:function:: self.Pyarchinit_db_management().insert_pylineeriferimento(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyquote(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_quote ..py:function:: self.Pyarchinit_db_management().insert_pyquote(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyquote_usm(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_quote_usm ..py:function:: self.Pyarchinit_db_management().insert_pyquote_usm(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyreperti(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_reperti ..py:function:: self.Pyarchinit_db_management().insert_pyreperti(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyripartizioni_spaziali(*arg)[sorgente]

Inserts the values into the layer pyarchinit_ripartizioni_spaziali ..py:function:: self.Pyarchinit_db_management().insert_pyripartizioni_spaziali(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pysezioni(*arg)[sorgente]

Inserts the values into the layer pyarchinit_sezioni ..py:function:: self.Pyarchinit_db_management().insert_pysezioni(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pysito_point(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_siti_point ..py:function:: self.Pyarchinit_db_management().insert_pysito_point(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pysito_polygon(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_siti_polygonal ..py:function:: self.Pyarchinit_db_management().insert_pysito_polygon(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pystrutture(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_strutture_ipotesi ..py:function:: self.Pyarchinit_db_management().insert_pystrutture(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pytomba(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_tafonomia ..py:function:: self.Pyarchinit_db_management().insert_pytomba(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyus(*arg)[sorgente]

Inserts the values into the dictionary pyunitastratigrafiche ..py:function:: self.Pyarchinit_db_management().insert_pyus(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyus_negative(*arg)[sorgente]

Inserts the values into the dictionary pyarchinit_us_negative_doc ..py:function:: self.Pyarchinit_db_management().insert_pyus_negative(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_pyusm(*arg)[sorgente]

Inserts the values into the dictionary pyunitastratigrafiche_usm ..py:function:: self.Pyarchinit_db_management().insert_pyusm(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_site_values(*arg)[sorgente]

Inserts the values into the layer site_table ..py:function:: self.Pyarchinit_db_management().insert_site_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_struttura_values(*arg)[sorgente]

Inserts the values into the layer struttura_table ..py:function:: self.Pyarchinit_db_management().insert_struttura_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_ut_values(*arg)[sorgente]

Inserts the values into the layer ut_table ..py:function:: self.Pyarchinit_db_management().insert_ut_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values(*arg)[sorgente]

Inserts the values into the layer us_table ..py:function:: self.Pyarchinit_db_management().insert_values(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_campioni(*arg)[sorgente]

Inserts the values into the layer campioni_table ..py:function:: self.Pyarchinit_db_management().insert_values_campioni(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_deteta(*arg)[sorgente]

Inserts the values into the layer deteta_table ..py:function:: self.Pyarchinit_db_management().insert_values_deteta(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_detsesso(*arg)[sorgente]

Inserts the values into the layer detsesso_table ..py:function:: self.Pyarchinit_db_management().insert_values_detsesso(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_documentazione(*arg)[sorgente]

Inserts the values into the layer documentazione_table ..py:function:: self.Pyarchinit_db_management().insert_values_documentazione(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_ind(*arg)[sorgente]

Inserts the values into the layer schedaind_table ..py:function:: self.Pyarchinit_db_management().insert_values_ind(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_reperti(*arg)[sorgente]

Inserts the values into the layer inventario_materiali_table ..py:function:: self.Pyarchinit_db_management().insert_values_reperti(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_thesaurus(*arg)[sorgente]

Inserts the values into the layer thesaurus ..py:function:: self.Pyarchinit_db_management().insert_values_thesaurus(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

insert_values_tomba(*arg)[sorgente]

Inserts the values into the layer tomba_table ..py:function:: self.Pyarchinit_db_management().insert_values_tomba(str)

param arg:

The arguments to the function which is passed to the function

type:

[str]

load_spatialite(dbapi_conn, connection_record)[sorgente]

Loads the spatialite database extension .

max_num_id(tc, f)[sorgente]

Returns the max number of that field in the table. It is used to determine the number of records in a table that have an auto increment field

param tc:

The table class ( ex.”US”)

param f:

The field id ( ex.”us”)

returns:

The max number of that field in the table. If there are no records 0 is

query(n)[sorgente]

Queries the database for a query. This is a convenience method for performing query queries that do not require a database connection.

Parametri:

n – The name of the class to query. This must be a string in the form’MyClass’e. g.

Ritorna:

A list of : class : . Row

query_bool(params, table)[sorgente]

Queries a table and returns True or False depending on the values of the params

param params:

Dictionary of key / value pairs to query the table

param table:

Name of the table to query ( ex : table1. table2

returns:

True or False depending on the

query_bool_special(params, table)[sorgente]

This method queries the database for boolean values that are special. If there are more than one value in the params dict it will return True or False

param params:

Dictionary of key / value pairs to search in

param table:

Name of the table to query

returns:

True or False depending on whether or not the query

query_distinct(table, query_params, distinct_field_name_params)[sorgente]

Queries the database for distinct values. This is a wrapper around sqlalchemy’s : func : ` ~sqlalchemy. orm. sessionmaker. query ` that allows to pass query parameters and distinct values to the query.

param table:

The table to query. This is passed by the : class : ` ~sqlalchemy. orm. sessionmaker. query ` object.

param query_params:

A list of tuples ( column name value ) that are used in the query

param distinct_field_name_params:

A list of tuples

query_distinct_sql(table, query_params, distinct_field_name_params)[sorgente]

Queries a table for distinct values. This is a wrapper around sqlalchemy’s execute method to avoid SQL injection

param table:

name of the table to query ( ex :”users”)

param query_params:

list of query parameters ( ex : [ (“username”” password”) ]

param distinct_field_name_params:

list of distinct

query_in_idus(id_list)[sorgente]

Query for US records in id_us. This is used to find US records that belong to a list of US IDs

param id_list:

List of IDs to search for.

returns:

A list of US records that belong to the list

query_operator(params, table)[sorgente]

This method queries the database for records that match the parameters. If there are multiple records the result will be a list of dictionaries

param params:

A list of parameters to match the query with

param table:

The table to query. It is used to create the query

returns:

A list of dictionaries that match the

query_sort(id_list, op, to, tc, idn)[sorgente]

Sorts a list of objects based on a list of primary keys. This is useful for sort functions that need to be called from a query method.

param id_list:

The list of primary keys

param op:

The operator to use for sorting

param to:

The type of object to sort (“ASC”” DESC”)

param tc:

The class to use for sorting (“TABLE”” COLUMNS’etc. )

param idn:

The name of the column in the table

returns:

A list of objects

query_where_text(c, v)[sorgente]

Query the PERIODIZZAZIONE table for a value that matches the criteria

param c:

The column to search for in the table.

param v:

The value to search for in the column.

returns:

The result of the query as a string. This is useful for debugging

remove_alltags_from_db_sql(s)[sorgente]

Remove all tags from database based on media name. This is used to prevent tagging a media that is no longer used in the database

param s:

media name to remove tags from. Should be a string

returns:

number of rows removed from the database. If there was an error nothing will be

remove_tags_from_db_sql(s)[sorgente]

Remove tags from database. This is used to remove tags that are no longer associated with an entity

param s:

id of the entity to remove tags from.

returns:

a tuple containing the number of rows removed and the SQL

run(stmt)[sorgente]

Executes a statement and returns a list of results. This is a wrapper around sqlalchemy’s execute method.

param stmt:

The SQLAlchemy Statement object. This should be an instance of sqlalchemy. engine. statement. Statement

returns:

A list of results

select_coord_from_db_sql(sito, area, us)[sorgente]

..py:function:: select_medianame_2_from_db_sql(str, str, int)

select_medianame_2_from_db_sql(sito, area, us)[sorgente]

..py:function:: select_medianame_2_from_db_sql(str, str, int)

select_medianame_from_db_sql(sito, area)[sorgente]

Select media from database. This is used to get the median name of a media in the media_to_entity_table ..py:function:: select_medianame_from_db_sql(str, str)

param sito:

Site where the media is located.

param area:

Area where the media is located. Example :”1 “

returns:

A list of 3 - tuples : ( filepath us media_name)

select_medianame_from_st_sql(sito, sigla, numero)[sorgente]

Select media names from struttura_table and media_thumb_table

param sito:

String with sito’s id ( ex : Sito archeologico )

param sigla:

String with sigla’s id ( ex : TB )

param numero:

String with numero’s id ( ex : 1 )

returns:

List with medieval names in format ( filepath media_name )

select_medianame_pot_from_db_sql(sito, area, us)[sorgente]

Select medias from database based on sito area and us. This is used to select medias about pottery that are in the database ..py:function:: select_medianame_pot_from_db_sql(str, str, int)

param sito:

sito of the pottery.

param area:

area of the pottery.

param us:

stratigraphic unit where pottery has been found.

returns:

list of tuples ( filepath potttery)

select_medianame_ra_from_db_sql(sito, area, us)[sorgente]

Select media names from database. This is used to get the median name from artefact ..py:function:: select_medianame_ra_from_db_sqll(str, str, int)

param sito:

name site

param area:

name area

param us:

name stratigraphic unit

returns:

list of tuples ( filepath media_name )

select_medianame_tb_from_db_sql(sito, area)[sorgente]

Select median name from database. This is used to get the file path of a Tomba and its thumbnail ..py:function:: select_medianame_tb_from_db_sql(str, str)

param sito:

Site ID of the Tomba

param area:

Area ID of the Tomba ( area_id )

returns:

list of tuples ( filepath media_name ) where filepath is the filepath of the

select_ra_from_db_sql(sito, area, us)[sorgente]

..py:function:: select_medianame_2_from_db_sql(str, str, int)

update(table_class_str, id_table_str, value_id_list, columns_name_list, values_update_list)[sorgente]

Updates a row in the database. This is a method for update operations that need to be performed on an existing row in the database.

param table_class_str:

The class of the table that contains the data to be updated.

param id_table_str:

The name of the table that contains the data to be updated.

param value_id_list:

A list of values that will be used to update the row’s id.

param columns_name_list:

A list of column names that will be updated.

param values_update_list:

A list of values that will be used to update the row’s values.

returns:

A dictionary with the changes that took place. It is returned as a dictionary

update_cont_per(s)[sorgente]

Updates the user content in the PERIODIZZAZIONE table

param s:

Name of site to be loaded

returns:

If the sieve is inserted or

update_find_check(table_class_str, id_table_str, value_id, find_check_value)[sorgente]

Update the find_check field in the database. This is used to determine if a record should be deleted or not

param table_class_str:

The table class of the object

param id_table_str:

The id table of the object

param value_id:

The id value of the object to delete

param find_check_value:

The value of the find_check field

returns:

True if the update was successful False if not ( in which case the database is in an unusable state

update_for()[sorgente]

Update toim inventario_materiali_table_toimp for all records

returns:

None Example :. from iota import Financial >>> Financial ( 0 ). update_for

9.7. pyarchinit Media Utility

Nota

Media_utility class is used for creating thumbnails of images. It utilizes the Image module from the Python Imaging Library (PIL) to open, resize, and save the image.


class Media_utility[sorgente]

# import the Image module import Image

# assign the image path to a variable using a raw string image_path = r»C: estsnake.png»

# open the image image = Image.open(image_path)

# resize the image to 150x110 width, height = (150, 110)

# assign width and height to size variable size = (width, height)

# create a new image path for the thumbnail new_image_thumbnail = r»C: estsnake_small.png»

# create the thumbnail using the Image.thumbnail method with the Image.ANTIALIAS filter image.thumbnail(size, Image.ANTIALIAS)

# save the new thumbnail image image.save(new_image_thumbnail)

#The class uses the Image module from the Python Imaging Library(PIL) to open, resize and save the image, the class uses the method thumbnail to create the thumbnail and it uses the Image.ANTIALIAS filter to smooth the image. The class also uses the method save to save the new thumbnail image.