id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
8,300
CalebBell/fluids
fluids/drag.py
integrate_drag_sphere
def integrate_drag_sphere(D, rhop, rho, mu, t, V=0, Method=None, distance=False): r'''Integrates the velocity and distance traveled by a particle moving at a speed which will converge to its terminal velocity. Performs an integration of the following expression for acceleration: ...
python
def integrate_drag_sphere(D, rhop, rho, mu, t, V=0, Method=None, distance=False): r'''Integrates the velocity and distance traveled by a particle moving at a speed which will converge to its terminal velocity. Performs an integration of the following expression for acceleration: ...
[ "def", "integrate_drag_sphere", "(", "D", ",", "rhop", ",", "rho", ",", "mu", ",", "t", ",", "V", "=", "0", ",", "Method", "=", "None", ",", "distance", "=", "False", ")", ":", "laminar_initial", "=", "Reynolds", "(", "V", "=", "V", ",", "rho", "...
r'''Integrates the velocity and distance traveled by a particle moving at a speed which will converge to its terminal velocity. Performs an integration of the following expression for acceleration: .. math:: a = \frac{g(\rho_p-\rho_f)}{\rho_p} - \frac{3C_D \rho_f u^2}{4D \rho_p} Parameters ...
[ "r", "Integrates", "the", "velocity", "and", "distance", "traveled", "by", "a", "particle", "moving", "at", "a", "speed", "which", "will", "converge", "to", "its", "terminal", "velocity", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/drag.py#L1260-L1414
8,301
CalebBell/fluids
fluids/fittings.py
bend_rounded_Ito
def bend_rounded_Ito(Di, angle, Re, rc=None, bend_diameters=None, roughness=0.0): '''Ito method as shown in Blevins. Curved friction factor as given in Blevins, with minor tweaks to be more accurate to the original methods. ''' if not rc: if bend_diameters is None: ...
python
def bend_rounded_Ito(Di, angle, Re, rc=None, bend_diameters=None, roughness=0.0): '''Ito method as shown in Blevins. Curved friction factor as given in Blevins, with minor tweaks to be more accurate to the original methods. ''' if not rc: if bend_diameters is None: ...
[ "def", "bend_rounded_Ito", "(", "Di", ",", "angle", ",", "Re", ",", "rc", "=", "None", ",", "bend_diameters", "=", "None", ",", "roughness", "=", "0.0", ")", ":", "if", "not", "rc", ":", "if", "bend_diameters", "is", "None", ":", "bend_diameters", "=",...
Ito method as shown in Blevins. Curved friction factor as given in Blevins, with minor tweaks to be more accurate to the original methods.
[ "Ito", "method", "as", "shown", "in", "Blevins", ".", "Curved", "friction", "factor", "as", "given", "in", "Blevins", "with", "minor", "tweaks", "to", "be", "more", "accurate", "to", "the", "original", "methods", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/fittings.py#L1193-L1224
8,302
CalebBell/fluids
fluids/design_climate.py
geopy_geolocator
def geopy_geolocator(): '''Lazy loader for geocoder from geopy. This currently loads the `Nominatim` geocode and returns an instance of it, taking ~2 us. ''' global geolocator if geolocator is None: try: from geopy.geocoders import Nominatim except ImportError: ...
python
def geopy_geolocator(): '''Lazy loader for geocoder from geopy. This currently loads the `Nominatim` geocode and returns an instance of it, taking ~2 us. ''' global geolocator if geolocator is None: try: from geopy.geocoders import Nominatim except ImportError: ...
[ "def", "geopy_geolocator", "(", ")", ":", "global", "geolocator", "if", "geolocator", "is", "None", ":", "try", ":", "from", "geopy", ".", "geocoders", "import", "Nominatim", "except", "ImportError", ":", "return", "None", "geolocator", "=", "Nominatim", "(", ...
Lazy loader for geocoder from geopy. This currently loads the `Nominatim` geocode and returns an instance of it, taking ~2 us.
[ "Lazy", "loader", "for", "geocoder", "from", "geopy", ".", "This", "currently", "loads", "the", "Nominatim", "geocode", "and", "returns", "an", "instance", "of", "it", "taking", "~2", "us", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L86-L98
8,303
CalebBell/fluids
fluids/design_climate.py
heating_degree_days
def heating_degree_days(T, T_base=F2K(65), truncate=True): r'''Calculates the heating degree days for a period of time. .. math:: \text{heating degree days} = max(T - T_{base}, 0) Parameters ---------- T : float Measured temperature; sometimes an average over a length of time is us...
python
def heating_degree_days(T, T_base=F2K(65), truncate=True): r'''Calculates the heating degree days for a period of time. .. math:: \text{heating degree days} = max(T - T_{base}, 0) Parameters ---------- T : float Measured temperature; sometimes an average over a length of time is us...
[ "def", "heating_degree_days", "(", "T", ",", "T_base", "=", "F2K", "(", "65", ")", ",", "truncate", "=", "True", ")", ":", "dd", "=", "T", "-", "T_base", "if", "truncate", "and", "dd", "<", "0.0", ":", "dd", "=", "0.0", "return", "dd" ]
r'''Calculates the heating degree days for a period of time. .. math:: \text{heating degree days} = max(T - T_{base}, 0) Parameters ---------- T : float Measured temperature; sometimes an average over a length of time is used, other times the average of the lowest and highest t...
[ "r", "Calculates", "the", "heating", "degree", "days", "for", "a", "period", "of", "time", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L193-L246
8,304
CalebBell/fluids
fluids/design_climate.py
cooling_degree_days
def cooling_degree_days(T, T_base=283.15, truncate=True): r'''Calculates the cooling degree days for a period of time. .. math:: \text{cooling degree days} = max(T_{base} - T, 0) Parameters ---------- T : float Measured temperature; sometimes an average over a length of time is use...
python
def cooling_degree_days(T, T_base=283.15, truncate=True): r'''Calculates the cooling degree days for a period of time. .. math:: \text{cooling degree days} = max(T_{base} - T, 0) Parameters ---------- T : float Measured temperature; sometimes an average over a length of time is use...
[ "def", "cooling_degree_days", "(", "T", ",", "T_base", "=", "283.15", ",", "truncate", "=", "True", ")", ":", "dd", "=", "T_base", "-", "T", "if", "truncate", "and", "dd", "<", "0.0", ":", "dd", "=", "0.0", "return", "dd" ]
r'''Calculates the cooling degree days for a period of time. .. math:: \text{cooling degree days} = max(T_{base} - T, 0) Parameters ---------- T : float Measured temperature; sometimes an average over a length of time is used, other times the average of the lowest and highest t...
[ "r", "Calculates", "the", "cooling", "degree", "days", "for", "a", "period", "of", "time", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L249-L300
8,305
CalebBell/fluids
fluids/design_climate.py
get_station_year_text
def get_station_year_text(WMO, WBAN, year): '''Basic method to download data from the GSOD database, given a station identifier and year. Parameters ---------- WMO : int or None World Meteorological Organization (WMO) identifiers, [-] WBAN : int or None Weather Bureau Army Na...
python
def get_station_year_text(WMO, WBAN, year): '''Basic method to download data from the GSOD database, given a station identifier and year. Parameters ---------- WMO : int or None World Meteorological Organization (WMO) identifiers, [-] WBAN : int or None Weather Bureau Army Na...
[ "def", "get_station_year_text", "(", "WMO", ",", "WBAN", ",", "year", ")", ":", "if", "WMO", "is", "None", ":", "WMO", "=", "999999", "if", "WBAN", "is", "None", ":", "WBAN", "=", "99999", "station", "=", "str", "(", "int", "(", "WMO", ")", ")", ...
Basic method to download data from the GSOD database, given a station identifier and year. Parameters ---------- WMO : int or None World Meteorological Organization (WMO) identifiers, [-] WBAN : int or None Weather Bureau Army Navy (WBAN) weather station identifier, [-] year ...
[ "Basic", "method", "to", "download", "data", "from", "the", "GSOD", "database", "given", "a", "station", "identifier", "and", "year", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/design_climate.py#L699-L760
8,306
CalebBell/fluids
fluids/packed_tower.py
_Stichlmair_flood_f
def _Stichlmair_flood_f(inputs, Vl, rhog, rhol, mug, voidage, specific_area, C1, C2, C3, H): '''Internal function which calculates the errors of the two Stichlmair objective functions, and their jacobian. ''' Vg, dP_irr = float(inputs[0]), float(inputs[1]) dp = 6.0*(1.0 - voi...
python
def _Stichlmair_flood_f(inputs, Vl, rhog, rhol, mug, voidage, specific_area, C1, C2, C3, H): '''Internal function which calculates the errors of the two Stichlmair objective functions, and their jacobian. ''' Vg, dP_irr = float(inputs[0]), float(inputs[1]) dp = 6.0*(1.0 - voi...
[ "def", "_Stichlmair_flood_f", "(", "inputs", ",", "Vl", ",", "rhog", ",", "rhol", ",", "mug", ",", "voidage", ",", "specific_area", ",", "C1", ",", "C2", ",", "C3", ",", "H", ")", ":", "Vg", ",", "dP_irr", "=", "float", "(", "inputs", "[", "0", "...
Internal function which calculates the errors of the two Stichlmair objective functions, and their jacobian.
[ "Internal", "function", "which", "calculates", "the", "errors", "of", "the", "two", "Stichlmair", "objective", "functions", "and", "their", "jacobian", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/packed_tower.py#L568-L586
8,307
CalebBell/fluids
fluids/packed_tower.py
Robbins
def Robbins(L, G, rhol, rhog, mul, H=1.0, Fpd=24.0): r'''Calculates pressure drop across a packed column, using the Robbins equation. Pressure drop is given by: .. math:: \Delta P = C_3 G_f^2 10^{C_4L_f}+0.4[L_f/20000]^{0.1}[C_3G_f^210^{C_4L_f}]^4 .. math:: G_f=G[0.075/\rho_g]^{0....
python
def Robbins(L, G, rhol, rhog, mul, H=1.0, Fpd=24.0): r'''Calculates pressure drop across a packed column, using the Robbins equation. Pressure drop is given by: .. math:: \Delta P = C_3 G_f^2 10^{C_4L_f}+0.4[L_f/20000]^{0.1}[C_3G_f^210^{C_4L_f}]^4 .. math:: G_f=G[0.075/\rho_g]^{0....
[ "def", "Robbins", "(", "L", ",", "G", ",", "rhol", ",", "rhog", ",", "mul", ",", "H", "=", "1.0", ",", "Fpd", "=", "24.0", ")", ":", "# Convert SI units to imperial for use in correlation", "L", "=", "L", "*", "737.33812", "# kg/s/m^2 to lb/hr/ft^2", "G", ...
r'''Calculates pressure drop across a packed column, using the Robbins equation. Pressure drop is given by: .. math:: \Delta P = C_3 G_f^2 10^{C_4L_f}+0.4[L_f/20000]^{0.1}[C_3G_f^210^{C_4L_f}]^4 .. math:: G_f=G[0.075/\rho_g]^{0.5}[F_{pd}/20]^{0.5}=986F_s[F_{pd}/20]^{0.5} .. math:...
[ "r", "Calculates", "pressure", "drop", "across", "a", "packed", "column", "using", "the", "Robbins", "equation", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/packed_tower.py#L741-L812
8,308
CalebBell/fluids
fluids/packed_bed.py
dP_packed_bed
def dP_packed_bed(dp, voidage, vs, rho, mu, L=1, Dt=None, sphericity=None, Method=None, AvailableMethods=False): r'''This function handles choosing which pressure drop in a packed bed correlation is used. Automatically select which correlation to use if none is provided. Returns None if in...
python
def dP_packed_bed(dp, voidage, vs, rho, mu, L=1, Dt=None, sphericity=None, Method=None, AvailableMethods=False): r'''This function handles choosing which pressure drop in a packed bed correlation is used. Automatically select which correlation to use if none is provided. Returns None if in...
[ "def", "dP_packed_bed", "(", "dp", ",", "voidage", ",", "vs", ",", "rho", ",", "mu", ",", "L", "=", "1", ",", "Dt", "=", "None", ",", "sphericity", "=", "None", ",", "Method", "=", "None", ",", "AvailableMethods", "=", "False", ")", ":", "def", "...
r'''This function handles choosing which pressure drop in a packed bed correlation is used. Automatically select which correlation to use if none is provided. Returns None if insufficient information is provided. Preferred correlations are 'Erdim, Akgiray & Demir' when tube diameter is not provided...
[ "r", "This", "function", "handles", "choosing", "which", "pressure", "drop", "in", "a", "packed", "bed", "correlation", "is", "used", ".", "Automatically", "select", "which", "correlation", "to", "use", "if", "none", "is", "provided", ".", "Returns", "None", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/packed_bed.py#L994-L1079
8,309
CalebBell/fluids
fluids/two_phase.py
Friedel
def Friedel(m, x, rhol, rhog, mul, mug, sigma, D, roughness=0, L=1): r'''Calculates two-phase pressure drop with the Friedel correlation. .. math:: \Delta P_{friction} = \Delta P_{lo} \phi_{lo}^2 .. math:: \phi_{lo}^2 = E + \frac{3.24FH}{Fr^{0.0454} We^{0.035}} .. math:: H = \...
python
def Friedel(m, x, rhol, rhog, mul, mug, sigma, D, roughness=0, L=1): r'''Calculates two-phase pressure drop with the Friedel correlation. .. math:: \Delta P_{friction} = \Delta P_{lo} \phi_{lo}^2 .. math:: \phi_{lo}^2 = E + \frac{3.24FH}{Fr^{0.0454} We^{0.035}} .. math:: H = \...
[ "def", "Friedel", "(", "m", ",", "x", ",", "rhol", ",", "rhog", ",", "mul", ",", "mug", ",", "sigma", ",", "D", ",", "roughness", "=", "0", ",", "L", "=", "1", ")", ":", "# Liquid-only properties, for calculation of E, dP_lo", "v_lo", "=", "m", "/", ...
r'''Calculates two-phase pressure drop with the Friedel correlation. .. math:: \Delta P_{friction} = \Delta P_{lo} \phi_{lo}^2 .. math:: \phi_{lo}^2 = E + \frac{3.24FH}{Fr^{0.0454} We^{0.035}} .. math:: H = \left(\frac{\rho_l}{\rho_g}\right)^{0.91}\left(\frac{\mu_g}{\mu_l} ...
[ "r", "Calculates", "two", "-", "phase", "pressure", "drop", "with", "the", "Friedel", "correlation", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/two_phase.py#L204-L324
8,310
CalebBell/fluids
fluids/atmosphere.py
airmass
def airmass(func, angle, H_max=86400.0, R_planet=6.371229E6, RI=1.000276): r'''Calculates mass of air per square meter in the atmosphere using a provided atmospheric model. The lowest air mass is calculated straight up; as the angle is lowered to nearer and nearer the horizon, the air mass increases, a...
python
def airmass(func, angle, H_max=86400.0, R_planet=6.371229E6, RI=1.000276): r'''Calculates mass of air per square meter in the atmosphere using a provided atmospheric model. The lowest air mass is calculated straight up; as the angle is lowered to nearer and nearer the horizon, the air mass increases, a...
[ "def", "airmass", "(", "func", ",", "angle", ",", "H_max", "=", "86400.0", ",", "R_planet", "=", "6.371229E6", ",", "RI", "=", "1.000276", ")", ":", "delta0", "=", "RI", "-", "1.0", "rho0", "=", "func", "(", "0.0", ")", "angle_term", "=", "cos", "(...
r'''Calculates mass of air per square meter in the atmosphere using a provided atmospheric model. The lowest air mass is calculated straight up; as the angle is lowered to nearer and nearer the horizon, the air mass increases, and can approach 40x or more the minimum airmass. .. math:: m(\gamm...
[ "r", "Calculates", "mass", "of", "air", "per", "square", "meter", "in", "the", "atmosphere", "using", "a", "provided", "atmospheric", "model", ".", "The", "lowest", "air", "mass", "is", "calculated", "straight", "up", ";", "as", "the", "angle", "is", "lowe...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/atmosphere.py#L689-L750
8,311
CalebBell/fluids
fluids/atmosphere.py
ATMOSPHERE_1976._get_ind_from_H
def _get_ind_from_H(H): r'''Method defined in the US Standard Atmosphere 1976 for determining the index of the layer a specified elevation is above. Levels are 0, 11E3, 20E3, 32E3, 47E3, 51E3, 71E3, 84852 meters respectively. ''' if H <= 0: return 0 for ind, ...
python
def _get_ind_from_H(H): r'''Method defined in the US Standard Atmosphere 1976 for determining the index of the layer a specified elevation is above. Levels are 0, 11E3, 20E3, 32E3, 47E3, 51E3, 71E3, 84852 meters respectively. ''' if H <= 0: return 0 for ind, ...
[ "def", "_get_ind_from_H", "(", "H", ")", ":", "if", "H", "<=", "0", ":", "return", "0", "for", "ind", ",", "Hi", "in", "enumerate", "(", "H_std", ")", ":", "if", "Hi", ">=", "H", ":", "return", "ind", "-", "1", "return", "7" ]
r'''Method defined in the US Standard Atmosphere 1976 for determining the index of the layer a specified elevation is above. Levels are 0, 11E3, 20E3, 32E3, 47E3, 51E3, 71E3, 84852 meters respectively.
[ "r", "Method", "defined", "in", "the", "US", "Standard", "Atmosphere", "1976", "for", "determining", "the", "index", "of", "the", "layer", "a", "specified", "elevation", "is", "above", ".", "Levels", "are", "0", "11E3", "20E3", "32E3", "47E3", "51E3", "71E...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/atmosphere.py#L154-L164
8,312
CalebBell/fluids
fluids/piping.py
gauge_from_t
def gauge_from_t(t, SI=True, schedule='BWG'): r'''Looks up the gauge of a given wire thickness of given schedule. Values are all non-linear, and tabulated internally. Parameters ---------- t : float Thickness, [m] SI : bool, optional If False, requires that the thickness is give...
python
def gauge_from_t(t, SI=True, schedule='BWG'): r'''Looks up the gauge of a given wire thickness of given schedule. Values are all non-linear, and tabulated internally. Parameters ---------- t : float Thickness, [m] SI : bool, optional If False, requires that the thickness is give...
[ "def", "gauge_from_t", "(", "t", ",", "SI", "=", "True", ",", "schedule", "=", "'BWG'", ")", ":", "tol", "=", "0.1", "# Handle units", "if", "SI", ":", "t_inch", "=", "round", "(", "t", "/", "inch", ",", "9", ")", "# all schedules are in inches", "else...
r'''Looks up the gauge of a given wire thickness of given schedule. Values are all non-linear, and tabulated internally. Parameters ---------- t : float Thickness, [m] SI : bool, optional If False, requires that the thickness is given in inches not meters schedule : str ...
[ "r", "Looks", "up", "the", "gauge", "of", "a", "given", "wire", "thickness", "of", "given", "schedule", ".", "Values", "are", "all", "non", "-", "linear", "and", "tabulated", "internally", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/piping.py#L349-L434
8,313
CalebBell/fluids
fluids/piping.py
t_from_gauge
def t_from_gauge(gauge, SI=True, schedule='BWG'): r'''Looks up the thickness of a given wire gauge of given schedule. Values are all non-linear, and tabulated internally. Parameters ---------- gauge : float-like Wire Gauge, [] SI : bool, optional If False, will return a thicknes...
python
def t_from_gauge(gauge, SI=True, schedule='BWG'): r'''Looks up the thickness of a given wire gauge of given schedule. Values are all non-linear, and tabulated internally. Parameters ---------- gauge : float-like Wire Gauge, [] SI : bool, optional If False, will return a thicknes...
[ "def", "t_from_gauge", "(", "gauge", ",", "SI", "=", "True", ",", "schedule", "=", "'BWG'", ")", ":", "try", ":", "sch_integers", ",", "sch_inch", ",", "sch_SI", ",", "decreasing", "=", "wire_schedules", "[", "schedule", "]", "except", ":", "raise", "Val...
r'''Looks up the thickness of a given wire gauge of given schedule. Values are all non-linear, and tabulated internally. Parameters ---------- gauge : float-like Wire Gauge, [] SI : bool, optional If False, will return a thickness in inches not meters schedule : str Gaug...
[ "r", "Looks", "up", "the", "thickness", "of", "a", "given", "wire", "gauge", "of", "given", "schedule", ".", "Values", "are", "all", "non", "-", "linear", "and", "tabulated", "internally", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/piping.py#L437-L493
8,314
CalebBell/fluids
fluids/safety_valve.py
API520_F2
def API520_F2(k, P1, P2): r'''Calculates coefficient F2 for subcritical flow for use in API 520 subcritical flow relief valve sizing. .. math:: F_2 = \sqrt{\left(\frac{k}{k-1}\right)r^\frac{2}{k} \left[\frac{1-r^\frac{k-1}{k}}{1-r}\right]} .. math:: r = \frac{P_2}{P_1} Par...
python
def API520_F2(k, P1, P2): r'''Calculates coefficient F2 for subcritical flow for use in API 520 subcritical flow relief valve sizing. .. math:: F_2 = \sqrt{\left(\frac{k}{k-1}\right)r^\frac{2}{k} \left[\frac{1-r^\frac{k-1}{k}}{1-r}\right]} .. math:: r = \frac{P_2}{P_1} Par...
[ "def", "API520_F2", "(", "k", ",", "P1", ",", "P2", ")", ":", "r", "=", "P2", "/", "P1", "return", "(", "k", "/", "(", "k", "-", "1", ")", "*", "r", "**", "(", "2.", "/", "k", ")", "*", "(", "(", "1", "-", "r", "**", "(", "(", "k", ...
r'''Calculates coefficient F2 for subcritical flow for use in API 520 subcritical flow relief valve sizing. .. math:: F_2 = \sqrt{\left(\frac{k}{k-1}\right)r^\frac{2}{k} \left[\frac{1-r^\frac{k-1}{k}}{1-r}\right]} .. math:: r = \frac{P_2}{P_1} Parameters ---------- k :...
[ "r", "Calculates", "coefficient", "F2", "for", "subcritical", "flow", "for", "use", "in", "API", "520", "subcritical", "flow", "relief", "valve", "sizing", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L130-L173
8,315
CalebBell/fluids
fluids/safety_valve.py
API520_SH
def API520_SH(T1, P1): r'''Calculates correction due to steam superheat for steam flow for use in API 520 relief valve sizing. 2D interpolation among a table with 28 pressures and 10 temperatures is performed. Parameters ---------- T1 : float Temperature of the fluid entering the valve...
python
def API520_SH(T1, P1): r'''Calculates correction due to steam superheat for steam flow for use in API 520 relief valve sizing. 2D interpolation among a table with 28 pressures and 10 temperatures is performed. Parameters ---------- T1 : float Temperature of the fluid entering the valve...
[ "def", "API520_SH", "(", "T1", ",", "P1", ")", ":", "if", "P1", ">", "20780325.0", ":", "# 20679E3+atm", "raise", "Exception", "(", "'For P above 20679 kPag, use the critical flow model'", ")", "if", "T1", ">", "922.15", ":", "raise", "Exception", "(", "'Superhe...
r'''Calculates correction due to steam superheat for steam flow for use in API 520 relief valve sizing. 2D interpolation among a table with 28 pressures and 10 temperatures is performed. Parameters ---------- T1 : float Temperature of the fluid entering the valve [K] P1 : float ...
[ "r", "Calculates", "correction", "due", "to", "steam", "superheat", "for", "steam", "flow", "for", "use", "in", "API", "520", "relief", "valve", "sizing", ".", "2D", "interpolation", "among", "a", "table", "with", "28", "pressures", "and", "10", "temperature...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L319-L361
8,316
CalebBell/fluids
fluids/safety_valve.py
API520_W
def API520_W(Pset, Pback): r'''Calculates capacity correction due to backpressure on balanced spring-loaded PRVs in liquid service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolation among a table ...
python
def API520_W(Pset, Pback): r'''Calculates capacity correction due to backpressure on balanced spring-loaded PRVs in liquid service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolation among a table ...
[ "def", "API520_W", "(", "Pset", ",", "Pback", ")", ":", "gauge_backpressure", "=", "(", "Pback", "-", "atm", ")", "/", "(", "Pset", "-", "atm", ")", "*", "100.0", "# in percent", "if", "gauge_backpressure", "<", "15.0", ":", "return", "1.0", "return", ...
r'''Calculates capacity correction due to backpressure on balanced spring-loaded PRVs in liquid service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolation among a table with 53 backpressures is pe...
[ "r", "Calculates", "capacity", "correction", "due", "to", "backpressure", "on", "balanced", "spring", "-", "loaded", "PRVs", "in", "liquid", "service", ".", "For", "pilot", "operated", "valves", "this", "is", "always", "1", ".", "Applicable", "up", "to", "50...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L383-L421
8,317
CalebBell/fluids
fluids/safety_valve.py
API520_B
def API520_B(Pset, Pback, overpressure=0.1): r'''Calculates capacity correction due to backpressure on balanced spring-loaded PRVs in vapor service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolati...
python
def API520_B(Pset, Pback, overpressure=0.1): r'''Calculates capacity correction due to backpressure on balanced spring-loaded PRVs in vapor service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolati...
[ "def", "API520_B", "(", "Pset", ",", "Pback", ",", "overpressure", "=", "0.1", ")", ":", "gauge_backpressure", "=", "(", "Pback", "-", "atm", ")", "/", "(", "Pset", "-", "atm", ")", "*", "100", "# in percent", "if", "overpressure", "not", "in", "[", ...
r'''Calculates capacity correction due to backpressure on balanced spring-loaded PRVs in vapor service. For pilot operated valves, this is always 1. Applicable up to 50% of the percent gauge backpressure, For use in API 520 relief valve sizing. 1D interpolation among a table with 53 backpressures is per...
[ "r", "Calculates", "capacity", "correction", "due", "to", "backpressure", "on", "balanced", "spring", "-", "loaded", "PRVs", "in", "vapor", "service", ".", "For", "pilot", "operated", "valves", "this", "is", "always", "1", ".", "Applicable", "up", "to", "50%...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L452-L504
8,318
CalebBell/fluids
fluids/safety_valve.py
API520_A_g
def API520_A_g(m, T, Z, MW, k, P1, P2=101325, Kd=0.975, Kb=1, Kc=1): r'''Calculates required relief valve area for an API 520 valve passing a gas or a vapor, at either critical or sub-critical flow. For critical flow: .. math:: A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}} For sub-critic...
python
def API520_A_g(m, T, Z, MW, k, P1, P2=101325, Kd=0.975, Kb=1, Kc=1): r'''Calculates required relief valve area for an API 520 valve passing a gas or a vapor, at either critical or sub-critical flow. For critical flow: .. math:: A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}} For sub-critic...
[ "def", "API520_A_g", "(", "m", ",", "T", ",", "Z", ",", "MW", ",", "k", ",", "P1", ",", "P2", "=", "101325", ",", "Kd", "=", "0.975", ",", "Kb", "=", "1", ",", "Kc", "=", "1", ")", ":", "P1", ",", "P2", "=", "P1", "/", "1000.", ",", "P2...
r'''Calculates required relief valve area for an API 520 valve passing a gas or a vapor, at either critical or sub-critical flow. For critical flow: .. math:: A = \frac{m}{CK_dP_1K_bK_c}\sqrt{\frac{TZ}{M}} For sub-critical flow: .. math:: A = \frac{17.9m}{F_2K_dK_c}\sqrt{\frac{TZ...
[ "r", "Calculates", "required", "relief", "valve", "area", "for", "an", "API", "520", "valve", "passing", "a", "gas", "or", "a", "vapor", "at", "either", "critical", "or", "sub", "-", "critical", "flow", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L507-L582
8,319
CalebBell/fluids
fluids/safety_valve.py
API520_A_steam
def API520_A_steam(m, T, P1, Kd=0.975, Kb=1, Kc=1): r'''Calculates required relief valve area for an API 520 valve passing a steam, at either saturation or superheat but not partially condensed. .. math:: A = \frac{190.5m}{P_1 K_d K_b K_c K_N K_{SH}} Parameters ---------- m : float ...
python
def API520_A_steam(m, T, P1, Kd=0.975, Kb=1, Kc=1): r'''Calculates required relief valve area for an API 520 valve passing a steam, at either saturation or superheat but not partially condensed. .. math:: A = \frac{190.5m}{P_1 K_d K_b K_c K_N K_{SH}} Parameters ---------- m : float ...
[ "def", "API520_A_steam", "(", "m", ",", "T", ",", "P1", ",", "Kd", "=", "0.975", ",", "Kb", "=", "1", ",", "Kc", "=", "1", ")", ":", "KN", "=", "API520_N", "(", "P1", ")", "KSH", "=", "API520_SH", "(", "T", ",", "P1", ")", "P1", "=", "P1", ...
r'''Calculates required relief valve area for an API 520 valve passing a steam, at either saturation or superheat but not partially condensed. .. math:: A = \frac{190.5m}{P_1 K_d K_b K_c K_N K_{SH}} Parameters ---------- m : float Mass flow rate of steam through the valve, [kg/s] ...
[ "r", "Calculates", "required", "relief", "valve", "area", "for", "an", "API", "520", "valve", "passing", "a", "steam", "at", "either", "saturation", "or", "superheat", "but", "not", "partially", "condensed", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/safety_valve.py#L585-L639
8,320
xhtml2pdf/xhtml2pdf
xhtml2pdf/context.py
pisaContext.getFile
def getFile(self, name, relative=None): """ Returns a file name or None """ if self.pathCallback is not None: return getFile(self._getFileDeprecated(name, relative)) return getFile(name, relative or self.pathDirectory)
python
def getFile(self, name, relative=None): """ Returns a file name or None """ if self.pathCallback is not None: return getFile(self._getFileDeprecated(name, relative)) return getFile(name, relative or self.pathDirectory)
[ "def", "getFile", "(", "self", ",", "name", ",", "relative", "=", "None", ")", ":", "if", "self", ".", "pathCallback", "is", "not", "None", ":", "return", "getFile", "(", "self", ".", "_getFileDeprecated", "(", "name", ",", "relative", ")", ")", "retur...
Returns a file name or None
[ "Returns", "a", "file", "name", "or", "None" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/context.py#L812-L818
8,321
xhtml2pdf/xhtml2pdf
xhtml2pdf/context.py
pisaContext.getFontName
def getFontName(self, names, default="helvetica"): """ Name of a font """ # print names, self.fontList if type(names) is not ListType: if type(names) not in six.string_types: names = str(names) names = names.strip().split(",") for n...
python
def getFontName(self, names, default="helvetica"): """ Name of a font """ # print names, self.fontList if type(names) is not ListType: if type(names) not in six.string_types: names = str(names) names = names.strip().split(",") for n...
[ "def", "getFontName", "(", "self", ",", "names", ",", "default", "=", "\"helvetica\"", ")", ":", "# print names, self.fontList", "if", "type", "(", "names", ")", "is", "not", "ListType", ":", "if", "type", "(", "names", ")", "not", "in", "six", ".", "str...
Name of a font
[ "Name", "of", "a", "font" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/context.py#L820-L835
8,322
xhtml2pdf/xhtml2pdf
xhtml2pdf/parser.py
pisaPreLoop
def pisaPreLoop(node, context, collect=False): """ Collect all CSS definitions """ data = u"" if node.nodeType == Node.TEXT_NODE and collect: data = node.data elif node.nodeType == Node.ELEMENT_NODE: name = node.tagName.lower() if name in ("style", "link"): ...
python
def pisaPreLoop(node, context, collect=False): """ Collect all CSS definitions """ data = u"" if node.nodeType == Node.TEXT_NODE and collect: data = node.data elif node.nodeType == Node.ELEMENT_NODE: name = node.tagName.lower() if name in ("style", "link"): ...
[ "def", "pisaPreLoop", "(", "node", ",", "context", ",", "collect", "=", "False", ")", ":", "data", "=", "u\"\"", "if", "node", ".", "nodeType", "==", "Node", ".", "TEXT_NODE", "and", "collect", ":", "data", "=", "node", ".", "data", "elif", "node", "...
Collect all CSS definitions
[ "Collect", "all", "CSS", "definitions" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/parser.py#L440-L476
8,323
xhtml2pdf/xhtml2pdf
xhtml2pdf/parser.py
pisaParser
def pisaParser(src, context, default_css="", xhtml=False, encoding=None, xml_output=None): """ - Parse HTML and get miniDOM - Extract CSS informations, add default CSS, parse CSS - Handle the document DOM itself and build reportlab story - Return Context object """ global CSSAttrCache C...
python
def pisaParser(src, context, default_css="", xhtml=False, encoding=None, xml_output=None): """ - Parse HTML and get miniDOM - Extract CSS informations, add default CSS, parse CSS - Handle the document DOM itself and build reportlab story - Return Context object """ global CSSAttrCache C...
[ "def", "pisaParser", "(", "src", ",", "context", ",", "default_css", "=", "\"\"", ",", "xhtml", "=", "False", ",", "encoding", "=", "None", ",", "xml_output", "=", "None", ")", ":", "global", "CSSAttrCache", "CSSAttrCache", "=", "{", "}", "if", "xhtml", ...
- Parse HTML and get miniDOM - Extract CSS informations, add default CSS, parse CSS - Handle the document DOM itself and build reportlab story - Return Context object
[ "-", "Parse", "HTML", "and", "get", "miniDOM", "-", "Extract", "CSS", "informations", "add", "default", "CSS", "parse", "CSS", "-", "Handle", "the", "document", "DOM", "itself", "and", "build", "reportlab", "story", "-", "Return", "Context", "object" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/parser.py#L703-L760
8,324
xhtml2pdf/xhtml2pdf
xhtml2pdf/paragraph.py
Line.doLayout
def doLayout(self, width): """ Align words in previous line. """ # Calculate dimensions self.width = width font_sizes = [0] + [frag.get("fontSize", 0) for frag in self] self.fontSize = max(font_sizes) self.height = self.lineHeight = max(frag * self.LINEH...
python
def doLayout(self, width): """ Align words in previous line. """ # Calculate dimensions self.width = width font_sizes = [0] + [frag.get("fontSize", 0) for frag in self] self.fontSize = max(font_sizes) self.height = self.lineHeight = max(frag * self.LINEH...
[ "def", "doLayout", "(", "self", ",", "width", ")", ":", "# Calculate dimensions", "self", ".", "width", "=", "width", "font_sizes", "=", "[", "0", "]", "+", "[", "frag", ".", "get", "(", "\"fontSize\"", ",", "0", ")", "for", "frag", "in", "self", "]"...
Align words in previous line.
[ "Align", "words", "in", "previous", "line", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L276-L293
8,325
xhtml2pdf/xhtml2pdf
xhtml2pdf/paragraph.py
Text.splitIntoLines
def splitIntoLines(self, maxWidth, maxHeight, splitted=False): """ Split text into lines and calculate X positions. If we need more space in height than available we return the rest of the text """ self.lines = [] self.height = 0 self.maxWidth = self.width = maxWi...
python
def splitIntoLines(self, maxWidth, maxHeight, splitted=False): """ Split text into lines and calculate X positions. If we need more space in height than available we return the rest of the text """ self.lines = [] self.height = 0 self.maxWidth = self.width = maxWi...
[ "def", "splitIntoLines", "(", "self", ",", "maxWidth", ",", "maxHeight", ",", "splitted", "=", "False", ")", ":", "self", ".", "lines", "=", "[", "]", "self", ".", "height", "=", "0", "self", ".", "maxWidth", "=", "self", ".", "width", "=", "maxWidth...
Split text into lines and calculate X positions. If we need more space in height than available we return the rest of the text
[ "Split", "text", "into", "lines", "and", "calculate", "X", "positions", ".", "If", "we", "need", "more", "space", "in", "height", "than", "available", "we", "return", "the", "rest", "of", "the", "text" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L330-L415
8,326
xhtml2pdf/xhtml2pdf
xhtml2pdf/paragraph.py
Text.dumpLines
def dumpLines(self): """ For debugging dump all line and their content """ for i, line in enumerate(self.lines): logger.debug("Line %d:", i) logger.debug(line.dumpFragments())
python
def dumpLines(self): """ For debugging dump all line and their content """ for i, line in enumerate(self.lines): logger.debug("Line %d:", i) logger.debug(line.dumpFragments())
[ "def", "dumpLines", "(", "self", ")", ":", "for", "i", ",", "line", "in", "enumerate", "(", "self", ".", "lines", ")", ":", "logger", ".", "debug", "(", "\"Line %d:\"", ",", "i", ")", "logger", ".", "debug", "(", "line", ".", "dumpFragments", "(", ...
For debugging dump all line and their content
[ "For", "debugging", "dump", "all", "line", "and", "their", "content" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L417-L423
8,327
xhtml2pdf/xhtml2pdf
xhtml2pdf/paragraph.py
Paragraph.wrap
def wrap(self, availWidth, availHeight): """ Determine the rectangle this paragraph really needs. """ # memorize available space self.avWidth = availWidth self.avHeight = availHeight logger.debug("*** wrap (%f, %f)", availWidth, availHeight) if not self...
python
def wrap(self, availWidth, availHeight): """ Determine the rectangle this paragraph really needs. """ # memorize available space self.avWidth = availWidth self.avHeight = availHeight logger.debug("*** wrap (%f, %f)", availWidth, availHeight) if not self...
[ "def", "wrap", "(", "self", ",", "availWidth", ",", "availHeight", ")", ":", "# memorize available space", "self", ".", "avWidth", "=", "availWidth", "self", ".", "avHeight", "=", "availHeight", "logger", ".", "debug", "(", "\"*** wrap (%f, %f)\"", ",", "availWi...
Determine the rectangle this paragraph really needs.
[ "Determine", "the", "rectangle", "this", "paragraph", "really", "needs", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L458-L481
8,328
xhtml2pdf/xhtml2pdf
xhtml2pdf/paragraph.py
Paragraph.split
def split(self, availWidth, availHeight): """ Split ourselves in two paragraphs. """ logger.debug("*** split (%f, %f)", availWidth, availHeight) splitted = [] if self.splitIndex: text1 = self.text[:self.splitIndex] text2 = self.text[self.splitInd...
python
def split(self, availWidth, availHeight): """ Split ourselves in two paragraphs. """ logger.debug("*** split (%f, %f)", availWidth, availHeight) splitted = [] if self.splitIndex: text1 = self.text[:self.splitIndex] text2 = self.text[self.splitInd...
[ "def", "split", "(", "self", ",", "availWidth", ",", "availHeight", ")", ":", "logger", ".", "debug", "(", "\"*** split (%f, %f)\"", ",", "availWidth", ",", "availHeight", ")", "splitted", "=", "[", "]", "if", "self", ".", "splitIndex", ":", "text1", "=", ...
Split ourselves in two paragraphs.
[ "Split", "ourselves", "in", "two", "paragraphs", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L483-L502
8,329
xhtml2pdf/xhtml2pdf
xhtml2pdf/paragraph.py
Paragraph.draw
def draw(self): """ Render the content of the paragraph. """ logger.debug("*** draw") if not self.text: return canvas = self.canv style = self.style canvas.saveState() # Draw box arround paragraph for debugging if self.debu...
python
def draw(self): """ Render the content of the paragraph. """ logger.debug("*** draw") if not self.text: return canvas = self.canv style = self.style canvas.saveState() # Draw box arround paragraph for debugging if self.debu...
[ "def", "draw", "(", "self", ")", ":", "logger", ".", "debug", "(", "\"*** draw\"", ")", "if", "not", "self", ".", "text", ":", "return", "canvas", "=", "self", ".", "canv", "style", "=", "self", ".", "style", "canvas", ".", "saveState", "(", ")", "...
Render the content of the paragraph.
[ "Render", "the", "content", "of", "the", "paragraph", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/paragraph.py#L504-L573
8,330
xhtml2pdf/xhtml2pdf
xhtml2pdf/pisa.py
showLogging
def showLogging(debug=False): """ Shortcut for enabling log dump """ try: log_level = logging.WARN log_format = LOG_FORMAT_DEBUG if debug: log_level = logging.DEBUG logging.basicConfig( level=log_level, format=log_format) except: ...
python
def showLogging(debug=False): """ Shortcut for enabling log dump """ try: log_level = logging.WARN log_format = LOG_FORMAT_DEBUG if debug: log_level = logging.DEBUG logging.basicConfig( level=log_level, format=log_format) except: ...
[ "def", "showLogging", "(", "debug", "=", "False", ")", ":", "try", ":", "log_level", "=", "logging", ".", "WARN", "log_format", "=", "LOG_FORMAT_DEBUG", "if", "debug", ":", "log_level", "=", "logging", ".", "DEBUG", "logging", ".", "basicConfig", "(", "lev...
Shortcut for enabling log dump
[ "Shortcut", "for", "enabling", "log", "dump" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/pisa.py#L420-L434
8,331
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/cssParser.py
CSSParser.parseFile
def parseFile(self, srcFile, closeFile=False): """Parses CSS file-like objects using the current cssBuilder. Use for external stylesheets.""" try: result = self.parse(srcFile.read()) finally: if closeFile: srcFile.close() return result
python
def parseFile(self, srcFile, closeFile=False): """Parses CSS file-like objects using the current cssBuilder. Use for external stylesheets.""" try: result = self.parse(srcFile.read()) finally: if closeFile: srcFile.close() return result
[ "def", "parseFile", "(", "self", ",", "srcFile", ",", "closeFile", "=", "False", ")", ":", "try", ":", "result", "=", "self", ".", "parse", "(", "srcFile", ".", "read", "(", ")", ")", "finally", ":", "if", "closeFile", ":", "srcFile", ".", "close", ...
Parses CSS file-like objects using the current cssBuilder. Use for external stylesheets.
[ "Parses", "CSS", "file", "-", "like", "objects", "using", "the", "current", "cssBuilder", ".", "Use", "for", "external", "stylesheets", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L427-L436
8,332
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/cssParser.py
CSSParser.parse
def parse(self, src): """Parses CSS string source using the current cssBuilder. Use for embedded stylesheets.""" self.cssBuilder.beginStylesheet() try: # XXX Some simple preprocessing src = cssSpecial.cleanupCSS(src) try: src, styles...
python
def parse(self, src): """Parses CSS string source using the current cssBuilder. Use for embedded stylesheets.""" self.cssBuilder.beginStylesheet() try: # XXX Some simple preprocessing src = cssSpecial.cleanupCSS(src) try: src, styles...
[ "def", "parse", "(", "self", ",", "src", ")", ":", "self", ".", "cssBuilder", ".", "beginStylesheet", "(", ")", "try", ":", "# XXX Some simple preprocessing", "src", "=", "cssSpecial", ".", "cleanupCSS", "(", "src", ")", "try", ":", "src", ",", "stylesheet...
Parses CSS string source using the current cssBuilder. Use for embedded stylesheets.
[ "Parses", "CSS", "string", "source", "using", "the", "current", "cssBuilder", ".", "Use", "for", "embedded", "stylesheets", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L439-L456
8,333
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/cssParser.py
CSSParser.parseInline
def parseInline(self, src): """Parses CSS inline source string using the current cssBuilder. Use to parse a tag's 'sytle'-like attribute.""" self.cssBuilder.beginInline() try: try: src, properties = self._parseDeclarationGroup(src.strip(), braces=False) ...
python
def parseInline(self, src): """Parses CSS inline source string using the current cssBuilder. Use to parse a tag's 'sytle'-like attribute.""" self.cssBuilder.beginInline() try: try: src, properties = self._parseDeclarationGroup(src.strip(), braces=False) ...
[ "def", "parseInline", "(", "self", ",", "src", ")", ":", "self", ".", "cssBuilder", ".", "beginInline", "(", ")", "try", ":", "try", ":", "src", ",", "properties", "=", "self", ".", "_parseDeclarationGroup", "(", "src", ".", "strip", "(", ")", ",", "...
Parses CSS inline source string using the current cssBuilder. Use to parse a tag's 'sytle'-like attribute.
[ "Parses", "CSS", "inline", "source", "string", "using", "the", "current", "cssBuilder", ".", "Use", "to", "parse", "a", "tag", "s", "sytle", "-", "like", "attribute", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L459-L474
8,334
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/cssParser.py
CSSParser.parseAttributes
def parseAttributes(self, attributes=None, **kwAttributes): """Parses CSS attribute source strings, and return as an inline stylesheet. Use to parse a tag's highly CSS-based attributes like 'font'. See also: parseSingleAttr """ attributes = attributes if attributes is not None e...
python
def parseAttributes(self, attributes=None, **kwAttributes): """Parses CSS attribute source strings, and return as an inline stylesheet. Use to parse a tag's highly CSS-based attributes like 'font'. See also: parseSingleAttr """ attributes = attributes if attributes is not None e...
[ "def", "parseAttributes", "(", "self", ",", "attributes", "=", "None", ",", "*", "*", "kwAttributes", ")", ":", "attributes", "=", "attributes", "if", "attributes", "is", "not", "None", "else", "{", "}", "if", "attributes", ":", "kwAttributes", ".", "updat...
Parses CSS attribute source strings, and return as an inline stylesheet. Use to parse a tag's highly CSS-based attributes like 'font'. See also: parseSingleAttr
[ "Parses", "CSS", "attribute", "source", "strings", "and", "return", "as", "an", "inline", "stylesheet", ".", "Use", "to", "parse", "a", "tag", "s", "highly", "CSS", "-", "based", "attributes", "like", "font", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L476-L501
8,335
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/cssParser.py
CSSParser.parseSingleAttr
def parseSingleAttr(self, attrValue): """Parse a single CSS attribute source string, and returns the built CSS expression. Use to parse a tag's highly CSS-based attributes like 'font'. See also: parseAttributes """ results = self.parseAttributes(temp=attrValue) if 'temp...
python
def parseSingleAttr(self, attrValue): """Parse a single CSS attribute source string, and returns the built CSS expression. Use to parse a tag's highly CSS-based attributes like 'font'. See also: parseAttributes """ results = self.parseAttributes(temp=attrValue) if 'temp...
[ "def", "parseSingleAttr", "(", "self", ",", "attrValue", ")", ":", "results", "=", "self", ".", "parseAttributes", "(", "temp", "=", "attrValue", ")", "if", "'temp'", "in", "results", "[", "1", "]", ":", "return", "results", "[", "1", "]", "[", "'temp'...
Parse a single CSS attribute source string, and returns the built CSS expression. Use to parse a tag's highly CSS-based attributes like 'font'. See also: parseAttributes
[ "Parse", "a", "single", "CSS", "attribute", "source", "string", "and", "returns", "the", "built", "CSS", "expression", ".", "Use", "to", "parse", "a", "tag", "s", "highly", "CSS", "-", "based", "attributes", "like", "font", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L504-L515
8,336
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/cssParser.py
CSSParser._parseAtFrame
def _parseAtFrame(self, src): """ XXX Proprietary for PDF """ src = src[len('@frame '):].lstrip() box, src = self._getIdent(src) src, properties = self._parseDeclarationGroup(src.lstrip()) result = [self.cssBuilder.atFrame(box, properties)] return src.lstr...
python
def _parseAtFrame(self, src): """ XXX Proprietary for PDF """ src = src[len('@frame '):].lstrip() box, src = self._getIdent(src) src, properties = self._parseDeclarationGroup(src.lstrip()) result = [self.cssBuilder.atFrame(box, properties)] return src.lstr...
[ "def", "_parseAtFrame", "(", "self", ",", "src", ")", ":", "src", "=", "src", "[", "len", "(", "'@frame '", ")", ":", "]", ".", "lstrip", "(", ")", "box", ",", "src", "=", "self", ".", "_getIdent", "(", "src", ")", "src", ",", "properties", "=", ...
XXX Proprietary for PDF
[ "XXX", "Proprietary", "for", "PDF" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/cssParser.py#L788-L796
8,337
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
ErrorMsg
def ErrorMsg(): """ Helper to get a nice traceback as string """ import traceback limit = None _type, value, tb = sys.exc_info() _list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(_type, value) return "Traceback (innermost last):\n" + "%-20s %s" % ( ...
python
def ErrorMsg(): """ Helper to get a nice traceback as string """ import traceback limit = None _type, value, tb = sys.exc_info() _list = traceback.format_tb(tb, limit) + \ traceback.format_exception_only(_type, value) return "Traceback (innermost last):\n" + "%-20s %s" % ( ...
[ "def", "ErrorMsg", "(", ")", ":", "import", "traceback", "limit", "=", "None", "_type", ",", "value", ",", "tb", "=", "sys", ".", "exc_info", "(", ")", "_list", "=", "traceback", ".", "format_tb", "(", "tb", ",", "limit", ")", "+", "traceback", ".", ...
Helper to get a nice traceback as string
[ "Helper", "to", "get", "a", "nice", "traceback", "as", "string" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L119-L131
8,338
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
transform_attrs
def transform_attrs(obj, keys, container, func, extras=None): """ Allows to apply one function to set of keys cheching if key is in container, also trasform ccs key to report lab keys. extras = Are extra params for func, it will be call like func(*[param1, param2]) obj = frag keys = [(reportl...
python
def transform_attrs(obj, keys, container, func, extras=None): """ Allows to apply one function to set of keys cheching if key is in container, also trasform ccs key to report lab keys. extras = Are extra params for func, it will be call like func(*[param1, param2]) obj = frag keys = [(reportl...
[ "def", "transform_attrs", "(", "obj", ",", "keys", ",", "container", ",", "func", ",", "extras", "=", "None", ")", ":", "cpextras", "=", "extras", "for", "reportlab", ",", "css", "in", "keys", ":", "extras", "=", "cpextras", "if", "extras", "is", "None...
Allows to apply one function to set of keys cheching if key is in container, also trasform ccs key to report lab keys. extras = Are extra params for func, it will be call like func(*[param1, param2]) obj = frag keys = [(reportlab, css), ... ] container = cssAttr
[ "Allows", "to", "apply", "one", "function", "to", "set", "of", "keys", "cheching", "if", "key", "is", "in", "container", "also", "trasform", "ccs", "key", "to", "report", "lab", "keys", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L140-L164
8,339
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
copy_attrs
def copy_attrs(obj1, obj2, attrs): """ Allows copy a list of attributes from object2 to object1. Useful for copy ccs attributes to fragment """ for attr in attrs: value = getattr(obj2, attr) if hasattr(obj2, attr) else None if value is None and isinstance(obj2, dict) and attr in ob...
python
def copy_attrs(obj1, obj2, attrs): """ Allows copy a list of attributes from object2 to object1. Useful for copy ccs attributes to fragment """ for attr in attrs: value = getattr(obj2, attr) if hasattr(obj2, attr) else None if value is None and isinstance(obj2, dict) and attr in ob...
[ "def", "copy_attrs", "(", "obj1", ",", "obj2", ",", "attrs", ")", ":", "for", "attr", "in", "attrs", ":", "value", "=", "getattr", "(", "obj2", ",", "attr", ")", "if", "hasattr", "(", "obj2", ",", "attr", ")", "else", "None", "if", "value", "is", ...
Allows copy a list of attributes from object2 to object1. Useful for copy ccs attributes to fragment
[ "Allows", "copy", "a", "list", "of", "attributes", "from", "object2", "to", "object1", ".", "Useful", "for", "copy", "ccs", "attributes", "to", "fragment" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L167-L176
8,340
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
set_value
def set_value(obj, attrs, value, _copy=False): """ Allows set the same value to a list of attributes """ for attr in attrs: if _copy: value = copy(value) setattr(obj, attr, value)
python
def set_value(obj, attrs, value, _copy=False): """ Allows set the same value to a list of attributes """ for attr in attrs: if _copy: value = copy(value) setattr(obj, attr, value)
[ "def", "set_value", "(", "obj", ",", "attrs", ",", "value", ",", "_copy", "=", "False", ")", ":", "for", "attr", "in", "attrs", ":", "if", "_copy", ":", "value", "=", "copy", "(", "value", ")", "setattr", "(", "obj", ",", "attr", ",", "value", ")...
Allows set the same value to a list of attributes
[ "Allows", "set", "the", "same", "value", "to", "a", "list", "of", "attributes" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L179-L186
8,341
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
getColor
def getColor(value, default=None): """ Convert to color value. This returns a Color object instance from a text bit. """ if isinstance(value, Color): return value value = str(value).strip().lower() if value == "transparent" or value == "none": return default if value in ...
python
def getColor(value, default=None): """ Convert to color value. This returns a Color object instance from a text bit. """ if isinstance(value, Color): return value value = str(value).strip().lower() if value == "transparent" or value == "none": return default if value in ...
[ "def", "getColor", "(", "value", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "Color", ")", ":", "return", "value", "value", "=", "str", "(", "value", ")", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", "va...
Convert to color value. This returns a Color object instance from a text bit.
[ "Convert", "to", "color", "value", ".", "This", "returns", "a", "Color", "object", "instance", "from", "a", "text", "bit", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L190-L214
8,342
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
getCoords
def getCoords(x, y, w, h, pagesize): """ As a stupid programmer I like to use the upper left corner of the document as the 0,0 coords therefore we need to do some fancy calculations """ #~ print pagesize ax, ay = pagesize if x < 0: x = ax + x if y < 0: y = ay + y ...
python
def getCoords(x, y, w, h, pagesize): """ As a stupid programmer I like to use the upper left corner of the document as the 0,0 coords therefore we need to do some fancy calculations """ #~ print pagesize ax, ay = pagesize if x < 0: x = ax + x if y < 0: y = ay + y ...
[ "def", "getCoords", "(", "x", ",", "y", ",", "w", ",", "h", ",", "pagesize", ")", ":", "#~ print pagesize", "ax", ",", "ay", "=", "pagesize", "if", "x", "<", "0", ":", "x", "=", "ax", "+", "x", "if", "y", "<", "0", ":", "y", "=", "ay", "+",...
As a stupid programmer I like to use the upper left corner of the document as the 0,0 coords therefore we need to do some fancy calculations
[ "As", "a", "stupid", "programmer", "I", "like", "to", "use", "the", "upper", "left", "corner", "of", "the", "document", "as", "the", "0", "0", "coords", "therefore", "we", "need", "to", "do", "some", "fancy", "calculations" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L336-L354
8,343
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
getFrameDimensions
def getFrameDimensions(data, page_width, page_height): """Calculate dimensions of a frame Returns left, top, width and height of the frame in points. """ box = data.get("-pdf-frame-box", []) if len(box) == 4: return [getSize(x) for x in box] top = getSize(data.get("top", 0)) left = ...
python
def getFrameDimensions(data, page_width, page_height): """Calculate dimensions of a frame Returns left, top, width and height of the frame in points. """ box = data.get("-pdf-frame-box", []) if len(box) == 4: return [getSize(x) for x in box] top = getSize(data.get("top", 0)) left = ...
[ "def", "getFrameDimensions", "(", "data", ",", "page_width", ",", "page_height", ")", ":", "box", "=", "data", ".", "get", "(", "\"-pdf-frame-box\"", ",", "[", "]", ")", "if", "len", "(", "box", ")", "==", "4", ":", "return", "[", "getSize", "(", "x"...
Calculate dimensions of a frame Returns left, top, width and height of the frame in points.
[ "Calculate", "dimensions", "of", "a", "frame" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L372-L407
8,344
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
getPos
def getPos(position, pagesize): """ Pair of coordinates """ position = str(position).split() if len(position) != 2: raise Exception("position not defined right way") x, y = [getSize(pos) for pos in position] return getCoords(x, y, None, None, pagesize)
python
def getPos(position, pagesize): """ Pair of coordinates """ position = str(position).split() if len(position) != 2: raise Exception("position not defined right way") x, y = [getSize(pos) for pos in position] return getCoords(x, y, None, None, pagesize)
[ "def", "getPos", "(", "position", ",", "pagesize", ")", ":", "position", "=", "str", "(", "position", ")", ".", "split", "(", ")", "if", "len", "(", "position", ")", "!=", "2", ":", "raise", "Exception", "(", "\"position not defined right way\"", ")", "x...
Pair of coordinates
[ "Pair", "of", "coordinates" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L411-L419
8,345
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
pisaTempFile.makeTempFile
def makeTempFile(self): """ Switch to next startegy. If an error occured, stay with the first strategy """ if self.strategy == 0: try: new_delegate = self.STRATEGIES[1]() new_delegate.write(self.getvalue()) self._delega...
python
def makeTempFile(self): """ Switch to next startegy. If an error occured, stay with the first strategy """ if self.strategy == 0: try: new_delegate = self.STRATEGIES[1]() new_delegate.write(self.getvalue()) self._delega...
[ "def", "makeTempFile", "(", "self", ")", ":", "if", "self", ".", "strategy", "==", "0", ":", "try", ":", "new_delegate", "=", "self", ".", "STRATEGIES", "[", "1", "]", "(", ")", "new_delegate", ".", "write", "(", "self", ".", "getvalue", "(", ")", ...
Switch to next startegy. If an error occured, stay with the first strategy
[ "Switch", "to", "next", "startegy", ".", "If", "an", "error", "occured", "stay", "with", "the", "first", "strategy" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L497-L511
8,346
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
pisaTempFile.getvalue
def getvalue(self): """ Get value of file. Work around for second strategy. Always returns bytes """ if self.strategy == 0: return self._delegate.getvalue() self._delegate.flush() self._delegate.seek(0) value = self._delegate.read() if...
python
def getvalue(self): """ Get value of file. Work around for second strategy. Always returns bytes """ if self.strategy == 0: return self._delegate.getvalue() self._delegate.flush() self._delegate.seek(0) value = self._delegate.read() if...
[ "def", "getvalue", "(", "self", ")", ":", "if", "self", ".", "strategy", "==", "0", ":", "return", "self", ".", "_delegate", ".", "getvalue", "(", ")", "self", ".", "_delegate", ".", "flush", "(", ")", "self", ".", "_delegate", ".", "seek", "(", "0...
Get value of file. Work around for second strategy. Always returns bytes
[ "Get", "value", "of", "file", ".", "Work", "around", "for", "second", "strategy", ".", "Always", "returns", "bytes" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L529-L542
8,347
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
pisaTempFile.write
def write(self, value): """ If capacity != -1 and length of file > capacity it is time to switch """ if self.capacity > 0 and self.strategy == 0: len_value = len(value) if len_value >= self.capacity: needs_new_strategy = True else: ...
python
def write(self, value): """ If capacity != -1 and length of file > capacity it is time to switch """ if self.capacity > 0 and self.strategy == 0: len_value = len(value) if len_value >= self.capacity: needs_new_strategy = True else: ...
[ "def", "write", "(", "self", ",", "value", ")", ":", "if", "self", ".", "capacity", ">", "0", "and", "self", ".", "strategy", "==", "0", ":", "len_value", "=", "len", "(", "value", ")", "if", "len_value", ">=", "self", ".", "capacity", ":", "needs_...
If capacity != -1 and length of file > capacity it is time to switch
[ "If", "capacity", "!", "=", "-", "1", "and", "length", "of", "file", ">", "capacity", "it", "is", "time", "to", "switch" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L544-L563
8,348
xhtml2pdf/xhtml2pdf
xhtml2pdf/util.py
pisaFileObject.setMimeTypeByName
def setMimeTypeByName(self, name): " Guess the mime type " mimetype = mimetypes.guess_type(name)[0] if mimetype is not None: self.mimetype = mimetypes.guess_type(name)[0].split(";")[0]
python
def setMimeTypeByName(self, name): " Guess the mime type " mimetype = mimetypes.guess_type(name)[0] if mimetype is not None: self.mimetype = mimetypes.guess_type(name)[0].split(";")[0]
[ "def", "setMimeTypeByName", "(", "self", ",", "name", ")", ":", "mimetype", "=", "mimetypes", ".", "guess_type", "(", "name", ")", "[", "0", "]", "if", "mimetype", "is", "not", "None", ":", "self", ".", "mimetype", "=", "mimetypes", ".", "guess_type", ...
Guess the mime type
[ "Guess", "the", "mime", "type" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/util.py#L732-L736
8,349
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
_sameFrag
def _sameFrag(f, g): """ returns 1 if two ParaFrags map out the same """ if (hasattr(f, 'cbDefn') or hasattr(g, 'cbDefn') or hasattr(f, 'lineBreak') or hasattr(g, 'lineBreak')): return 0 for a in ('fontName', 'fontSize', 'textColor', 'backColor', 'rise', 'underline', 'strike', 'link'): ...
python
def _sameFrag(f, g): """ returns 1 if two ParaFrags map out the same """ if (hasattr(f, 'cbDefn') or hasattr(g, 'cbDefn') or hasattr(f, 'lineBreak') or hasattr(g, 'lineBreak')): return 0 for a in ('fontName', 'fontSize', 'textColor', 'backColor', 'rise', 'underline', 'strike', 'link'): ...
[ "def", "_sameFrag", "(", "f", ",", "g", ")", ":", "if", "(", "hasattr", "(", "f", ",", "'cbDefn'", ")", "or", "hasattr", "(", "g", ",", "'cbDefn'", ")", "or", "hasattr", "(", "f", ",", "'lineBreak'", ")", "or", "hasattr", "(", "g", ",", "'lineBre...
returns 1 if two ParaFrags map out the same
[ "returns", "1", "if", "two", "ParaFrags", "map", "out", "the", "same" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L417-L426
8,350
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
_drawBullet
def _drawBullet(canvas, offset, cur_y, bulletText, style): """ draw a bullet text could be a simple string or a frag list """ tx2 = canvas.beginText(style.bulletIndent, cur_y + getattr(style, "bulletOffsetY", 0)) tx2.setFont(style.bulletFontName, style.bulletFontSize) tx2.setFillColor(hasattr(s...
python
def _drawBullet(canvas, offset, cur_y, bulletText, style): """ draw a bullet text could be a simple string or a frag list """ tx2 = canvas.beginText(style.bulletIndent, cur_y + getattr(style, "bulletOffsetY", 0)) tx2.setFont(style.bulletFontName, style.bulletFontSize) tx2.setFillColor(hasattr(s...
[ "def", "_drawBullet", "(", "canvas", ",", "offset", ",", "cur_y", ",", "bulletText", ",", "style", ")", ":", "tx2", "=", "canvas", ".", "beginText", "(", "style", ".", "bulletIndent", ",", "cur_y", "+", "getattr", "(", "style", ",", "\"bulletOffsetY\"", ...
draw a bullet text could be a simple string or a frag list
[ "draw", "a", "bullet", "text", "could", "be", "a", "simple", "string", "or", "a", "frag", "list" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L536-L570
8,351
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
splitLines0
def splitLines0(frags, widths): """ given a list of ParaFrags we return a list of ParaLines each ParaLine has 1) ExtraSpace 2) blankCount 3) [textDefns....] each text definition is a (ParaFrag, start, limit) triplet """ #initialise the algorithm lineNum = 0 maxW = wi...
python
def splitLines0(frags, widths): """ given a list of ParaFrags we return a list of ParaLines each ParaLine has 1) ExtraSpace 2) blankCount 3) [textDefns....] each text definition is a (ParaFrag, start, limit) triplet """ #initialise the algorithm lineNum = 0 maxW = wi...
[ "def", "splitLines0", "(", "frags", ",", "widths", ")", ":", "#initialise the algorithm", "lineNum", "=", "0", "maxW", "=", "widths", "[", "lineNum", "]", "i", "=", "-", "1", "l", "=", "len", "(", "frags", ")", "lim", "=", "start", "=", "0", "text", ...
given a list of ParaFrags we return a list of ParaLines each ParaLine has 1) ExtraSpace 2) blankCount 3) [textDefns....] each text definition is a (ParaFrag, start, limit) triplet
[ "given", "a", "list", "of", "ParaFrags", "we", "return", "a", "list", "of", "ParaLines" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L592-L652
8,352
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
cjkFragSplit
def cjkFragSplit(frags, maxWidths, calcBounds, encoding='utf8'): """ This attempts to be wordSplit for frags using the dumb algorithm """ from reportlab.rl_config import _FUZZ U = [] # get a list of single glyphs with their widths etc etc for f in frags: text = f.text if not i...
python
def cjkFragSplit(frags, maxWidths, calcBounds, encoding='utf8'): """ This attempts to be wordSplit for frags using the dumb algorithm """ from reportlab.rl_config import _FUZZ U = [] # get a list of single glyphs with their widths etc etc for f in frags: text = f.text if not i...
[ "def", "cjkFragSplit", "(", "frags", ",", "maxWidths", ",", "calcBounds", ",", "encoding", "=", "'utf8'", ")", ":", "from", "reportlab", ".", "rl_config", "import", "_FUZZ", "U", "=", "[", "]", "# get a list of single glyphs with their widths etc etc", "for", "f",...
This attempts to be wordSplit for frags using the dumb algorithm
[ "This", "attempts", "to", "be", "wordSplit", "for", "frags", "using", "the", "dumb", "algorithm" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L854-L904
8,353
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
Paragraph.minWidth
def minWidth(self): """ Attempt to determine a minimum sensible width """ frags = self.frags nFrags = len(frags) if not nFrags: return 0 if nFrags == 1: f = frags[0] fS = f.fontSize fN = f.fontName words = hasattr(f...
python
def minWidth(self): """ Attempt to determine a minimum sensible width """ frags = self.frags nFrags = len(frags) if not nFrags: return 0 if nFrags == 1: f = frags[0] fS = f.fontSize fN = f.fontName words = hasattr(f...
[ "def", "minWidth", "(", "self", ")", ":", "frags", "=", "self", ".", "frags", "nFrags", "=", "len", "(", "frags", ")", "if", "not", "nFrags", ":", "return", "0", "if", "nFrags", "==", "1", ":", "f", "=", "frags", "[", "0", "]", "fS", "=", "f", ...
Attempt to determine a minimum sensible width
[ "Attempt", "to", "determine", "a", "minimum", "sensible", "width" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L1043-L1060
8,354
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
Paragraph.breakLinesCJK
def breakLinesCJK(self, width): """Initially, the dumbest possible wrapping algorithm. Cannot handle font variations.""" if self.debug: print (id(self), "breakLinesCJK") if not isinstance(width, (list, tuple)): maxWidths = [width] else: maxWi...
python
def breakLinesCJK(self, width): """Initially, the dumbest possible wrapping algorithm. Cannot handle font variations.""" if self.debug: print (id(self), "breakLinesCJK") if not isinstance(width, (list, tuple)): maxWidths = [width] else: maxWi...
[ "def", "breakLinesCJK", "(", "self", ",", "width", ")", ":", "if", "self", ".", "debug", ":", "print", "(", "id", "(", "self", ")", ",", "\"breakLinesCJK\"", ")", "if", "not", "isinstance", "(", "width", ",", "(", "list", ",", "tuple", ")", ")", ":...
Initially, the dumbest possible wrapping algorithm. Cannot handle font variations.
[ "Initially", "the", "dumbest", "possible", "wrapping", "algorithm", ".", "Cannot", "handle", "font", "variations", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L1409-L1456
8,355
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
Paragraph.getPlainText
def getPlainText(self, identify=None): """ Convenience function for templates which want access to the raw text, without XML tags. """ frags = getattr(self, 'frags', None) if frags: plains = [] for frag in frags: if hasattr(frag, '...
python
def getPlainText(self, identify=None): """ Convenience function for templates which want access to the raw text, without XML tags. """ frags = getattr(self, 'frags', None) if frags: plains = [] for frag in frags: if hasattr(frag, '...
[ "def", "getPlainText", "(", "self", ",", "identify", "=", "None", ")", ":", "frags", "=", "getattr", "(", "self", ",", "'frags'", ",", "None", ")", "if", "frags", ":", "plains", "=", "[", "]", "for", "frag", "in", "frags", ":", "if", "hasattr", "("...
Convenience function for templates which want access to the raw text, without XML tags.
[ "Convenience", "function", "for", "templates", "which", "want", "access", "to", "the", "raw", "text", "without", "XML", "tags", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L1657-L1675
8,356
xhtml2pdf/xhtml2pdf
xhtml2pdf/reportlab_paragraph.py
Paragraph.getActualLineWidths0
def getActualLineWidths0(self): """ Convenience function; tells you how wide each line actually is. For justified styles, this will be the same as the wrap width; for others it might be useful for seeing if paragraphs will fit in spaces. """ assert hasattr(self,...
python
def getActualLineWidths0(self): """ Convenience function; tells you how wide each line actually is. For justified styles, this will be the same as the wrap width; for others it might be useful for seeing if paragraphs will fit in spaces. """ assert hasattr(self,...
[ "def", "getActualLineWidths0", "(", "self", ")", ":", "assert", "hasattr", "(", "self", ",", "'width'", ")", ",", "\"Cannot call this method before wrap()\"", "if", "self", ".", "blPara", ".", "kind", ":", "func", "=", "lambda", "frag", ",", "w", "=", "self"...
Convenience function; tells you how wide each line actually is. For justified styles, this will be the same as the wrap width; for others it might be useful for seeing if paragraphs will fit in spaces.
[ "Convenience", "function", ";", "tells", "you", "how", "wide", "each", "line", "actually", "is", ".", "For", "justified", "styles", "this", "will", "be", "the", "same", "as", "the", "wrap", "width", ";", "for", "others", "it", "might", "be", "useful", "f...
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/reportlab_paragraph.py#L1677-L1690
8,357
xhtml2pdf/xhtml2pdf
demo/djangoproject/views.py
link_callback
def link_callback(uri, rel): """ Convert HTML URIs to absolute system paths so xhtml2pdf can access those resources """ # use short variable names sUrl = settings.STATIC_URL # Typically /static/ sRoot = settings.STATIC_ROOT # Typically /home/userX/project_static/ mUrl = settings....
python
def link_callback(uri, rel): """ Convert HTML URIs to absolute system paths so xhtml2pdf can access those resources """ # use short variable names sUrl = settings.STATIC_URL # Typically /static/ sRoot = settings.STATIC_ROOT # Typically /home/userX/project_static/ mUrl = settings....
[ "def", "link_callback", "(", "uri", ",", "rel", ")", ":", "# use short variable names", "sUrl", "=", "settings", ".", "STATIC_URL", "# Typically /static/", "sRoot", "=", "settings", ".", "STATIC_ROOT", "# Typically /home/userX/project_static/", "mUrl", "=", "settings", ...
Convert HTML URIs to absolute system paths so xhtml2pdf can access those resources
[ "Convert", "HTML", "URIs", "to", "absolute", "system", "paths", "so", "xhtml2pdf", "can", "access", "those", "resources" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/demo/djangoproject/views.py#L23-L48
8,358
xhtml2pdf/xhtml2pdf
demo/tgpisa/tgpisa/commands.py
start
def start(): """Start the CherryPy application server.""" setupdir = dirname(dirname(__file__)) curdir = os.getcwd() # First look on the command line for a desired config file, # if it's not on the command line, then look for 'setup.py' # in the current directory. If there, load configuration ...
python
def start(): """Start the CherryPy application server.""" setupdir = dirname(dirname(__file__)) curdir = os.getcwd() # First look on the command line for a desired config file, # if it's not on the command line, then look for 'setup.py' # in the current directory. If there, load configuration ...
[ "def", "start", "(", ")", ":", "setupdir", "=", "dirname", "(", "dirname", "(", "__file__", ")", ")", "curdir", "=", "os", ".", "getcwd", "(", ")", "# First look on the command line for a desired config file,", "# if it's not on the command line, then look for 'setup.py'"...
Start the CherryPy application server.
[ "Start", "the", "CherryPy", "application", "server", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/demo/tgpisa/tgpisa/commands.py#L20-L52
8,359
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/css.py
CSSRuleset.mergeStyles
def mergeStyles(self, styles): " XXX Bugfix for use in PISA " for k, v in six.iteritems(styles): if k in self and self[k]: self[k] = copy.copy(self[k]) self[k].update(v) else: self[k] = v
python
def mergeStyles(self, styles): " XXX Bugfix for use in PISA " for k, v in six.iteritems(styles): if k in self and self[k]: self[k] = copy.copy(self[k]) self[k].update(v) else: self[k] = v
[ "def", "mergeStyles", "(", "self", ",", "styles", ")", ":", "for", "k", ",", "v", "in", "six", ".", "iteritems", "(", "styles", ")", ":", "if", "k", "in", "self", "and", "self", "[", "k", "]", ":", "self", "[", "k", "]", "=", "copy", ".", "co...
XXX Bugfix for use in PISA
[ "XXX", "Bugfix", "for", "use", "in", "PISA" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/css.py#L697-L704
8,360
xhtml2pdf/xhtml2pdf
xhtml2pdf/w3c/css.py
CSSBuilder.atPage
def atPage(self, page, pseudopage, declarations): """ This is overriden by xhtml2pdf.context.pisaCSSBuilder """ return self.ruleset([self.selector('*')], declarations)
python
def atPage(self, page, pseudopage, declarations): """ This is overriden by xhtml2pdf.context.pisaCSSBuilder """ return self.ruleset([self.selector('*')], declarations)
[ "def", "atPage", "(", "self", ",", "page", ",", "pseudopage", ",", "declarations", ")", ":", "return", "self", ".", "ruleset", "(", "[", "self", ".", "selector", "(", "'*'", ")", "]", ",", "declarations", ")" ]
This is overriden by xhtml2pdf.context.pisaCSSBuilder
[ "This", "is", "overriden", "by", "xhtml2pdf", ".", "context", ".", "pisaCSSBuilder" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/w3c/css.py#L905-L909
8,361
xhtml2pdf/xhtml2pdf
xhtml2pdf/xhtml2pdf_reportlab.py
PmlBaseDoc.handle_nextPageTemplate
def handle_nextPageTemplate(self, pt): ''' if pt has also templates for even and odd page convert it to list ''' has_left_template = self._has_template_for_name(pt + '_left') has_right_template = self._has_template_for_name(pt + '_right') if has_left_template and has_rig...
python
def handle_nextPageTemplate(self, pt): ''' if pt has also templates for even and odd page convert it to list ''' has_left_template = self._has_template_for_name(pt + '_left') has_right_template = self._has_template_for_name(pt + '_right') if has_left_template and has_rig...
[ "def", "handle_nextPageTemplate", "(", "self", ",", "pt", ")", ":", "has_left_template", "=", "self", ".", "_has_template_for_name", "(", "pt", "+", "'_left'", ")", "has_right_template", "=", "self", ".", "_has_template_for_name", "(", "pt", "+", "'_right'", ")"...
if pt has also templates for even and odd page convert it to list
[ "if", "pt", "has", "also", "templates", "for", "even", "and", "odd", "page", "convert", "it", "to", "list" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/xhtml2pdf_reportlab.py#L125-L169
8,362
xhtml2pdf/xhtml2pdf
xhtml2pdf/xhtml2pdf_reportlab.py
PmlImageReader.getRGBData
def getRGBData(self): "Return byte array of RGB data as string" if self._data is None: self._dataA = None if sys.platform[0:4] == 'java': import jarray # TODO: Move to top. from java.awt.image import PixelGrabber width, height = s...
python
def getRGBData(self): "Return byte array of RGB data as string" if self._data is None: self._dataA = None if sys.platform[0:4] == 'java': import jarray # TODO: Move to top. from java.awt.image import PixelGrabber width, height = s...
[ "def", "getRGBData", "(", "self", ")", ":", "if", "self", ".", "_data", "is", "None", ":", "self", ".", "_dataA", "=", "None", "if", "sys", ".", "platform", "[", "0", ":", "4", "]", "==", "'java'", ":", "import", "jarray", "# TODO: Move to top.", "fr...
Return byte array of RGB data as string
[ "Return", "byte", "array", "of", "RGB", "data", "as", "string" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/xhtml2pdf_reportlab.py#L396-L434
8,363
xhtml2pdf/xhtml2pdf
xhtml2pdf/xhtml2pdf_reportlab.py
PmlImage.wrap
def wrap(self, availWidth, availHeight): " This can be called more than once! Do not overwrite important data like drawWidth " availHeight = self.setMaxHeight(availHeight) # print "image wrap", id(self), availWidth, availHeight, self.drawWidth, self.drawHeight width = min(self.drawWidth,...
python
def wrap(self, availWidth, availHeight): " This can be called more than once! Do not overwrite important data like drawWidth " availHeight = self.setMaxHeight(availHeight) # print "image wrap", id(self), availWidth, availHeight, self.drawWidth, self.drawHeight width = min(self.drawWidth,...
[ "def", "wrap", "(", "self", ",", "availWidth", ",", "availHeight", ")", ":", "availHeight", "=", "self", ".", "setMaxHeight", "(", "availHeight", ")", "# print \"image wrap\", id(self), availWidth, availHeight, self.drawWidth, self.drawHeight", "width", "=", "min", "(", ...
This can be called more than once! Do not overwrite important data like drawWidth
[ "This", "can", "be", "called", "more", "than", "once!", "Do", "not", "overwrite", "important", "data", "like", "drawWidth" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/xhtml2pdf_reportlab.py#L490-L502
8,364
xhtml2pdf/xhtml2pdf
xhtml2pdf/xhtml2pdf_reportlab.py
PmlTable._normWidth
def _normWidth(self, w, maxw): """ Helper for calculating percentages """ if type(w) == type(""): w = ((maxw / 100.0) * float(w[: - 1])) elif (w is None) or (w == "*"): w = maxw return min(w, maxw)
python
def _normWidth(self, w, maxw): """ Helper for calculating percentages """ if type(w) == type(""): w = ((maxw / 100.0) * float(w[: - 1])) elif (w is None) or (w == "*"): w = maxw return min(w, maxw)
[ "def", "_normWidth", "(", "self", ",", "w", ",", "maxw", ")", ":", "if", "type", "(", "w", ")", "==", "type", "(", "\"\"", ")", ":", "w", "=", "(", "(", "maxw", "/", "100.0", ")", "*", "float", "(", "w", "[", ":", "-", "1", "]", ")", ")",...
Helper for calculating percentages
[ "Helper", "for", "calculating", "percentages" ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/xhtml2pdf_reportlab.py#L707-L715
8,365
xhtml2pdf/xhtml2pdf
xhtml2pdf/xhtml2pdf_reportlab.py
PmlTableOfContents.wrap
def wrap(self, availWidth, availHeight): """ All table properties should be known by now. """ widths = (availWidth - self.rightColumnWidth, self.rightColumnWidth) # makes an internal table which does all the work. # we draw the LAST RUN's entries! If ...
python
def wrap(self, availWidth, availHeight): """ All table properties should be known by now. """ widths = (availWidth - self.rightColumnWidth, self.rightColumnWidth) # makes an internal table which does all the work. # we draw the LAST RUN's entries! If ...
[ "def", "wrap", "(", "self", ",", "availWidth", ",", "availHeight", ")", ":", "widths", "=", "(", "availWidth", "-", "self", ".", "rightColumnWidth", ",", "self", ".", "rightColumnWidth", ")", "# makes an internal table which does all the work.", "# we draw the LAST RU...
All table properties should be known by now.
[ "All", "table", "properties", "should", "be", "known", "by", "now", "." ]
230357a392f48816532d3c2fa082a680b80ece48
https://github.com/xhtml2pdf/xhtml2pdf/blob/230357a392f48816532d3c2fa082a680b80ece48/xhtml2pdf/xhtml2pdf_reportlab.py#L788-L839
8,366
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession._spawn_child
def _spawn_child(self, command, args=None, timeout=shutit_global.shutit_global_object.default_timeout, maxread=2000, searchwindowsize=None, env=None, ignore_sighup=False, echo=...
python
def _spawn_child(self, command, args=None, timeout=shutit_global.shutit_global_object.default_timeout, maxread=2000, searchwindowsize=None, env=None, ignore_sighup=False, echo=...
[ "def", "_spawn_child", "(", "self", ",", "command", ",", "args", "=", "None", ",", "timeout", "=", "shutit_global", ".", "shutit_global_object", ".", "default_timeout", ",", "maxread", "=", "2000", ",", "searchwindowsize", "=", "None", ",", "env", "=", "None...
spawn a child, and manage the delaybefore send setting to 0
[ "spawn", "a", "child", "and", "manage", "the", "delaybefore", "send", "setting", "to", "0" ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L149-L186
8,367
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.sendline
def sendline(self, sendspec): """Sends line, handling background and newline directives. True means: 'all handled here ok' False means: you'll need to 'expect' the right thing from here. """ assert not sendspec.started, shutit_util.print_debug() shutit = self.shutit shutit.log('Sending in pexpect session...
python
def sendline(self, sendspec): """Sends line, handling background and newline directives. True means: 'all handled here ok' False means: you'll need to 'expect' the right thing from here. """ assert not sendspec.started, shutit_util.print_debug() shutit = self.shutit shutit.log('Sending in pexpect session...
[ "def", "sendline", "(", "self", ",", "sendspec", ")", ":", "assert", "not", "sendspec", ".", "started", ",", "shutit_util", ".", "print_debug", "(", ")", "shutit", "=", "self", ".", "shutit", "shutit", ".", "log", "(", "'Sending in pexpect session ('", "+", ...
Sends line, handling background and newline directives. True means: 'all handled here ok' False means: you'll need to 'expect' the right thing from here.
[ "Sends", "line", "handling", "background", "and", "newline", "directives", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L189-L226
8,368
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.wait
def wait(self, cadence=2, sendspec=None): """Does not return until all background commands are completed. """ shutit = self.shutit shutit.log('In wait.', level=logging.DEBUG) if sendspec: cadence = sendspec.wait_cadence shutit.log('Login stack is:\n' + str(self.login_stack), level=logging.DEBUG) while ...
python
def wait(self, cadence=2, sendspec=None): """Does not return until all background commands are completed. """ shutit = self.shutit shutit.log('In wait.', level=logging.DEBUG) if sendspec: cadence = sendspec.wait_cadence shutit.log('Login stack is:\n' + str(self.login_stack), level=logging.DEBUG) while ...
[ "def", "wait", "(", "self", ",", "cadence", "=", "2", ",", "sendspec", "=", "None", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "log", "(", "'In wait.'", ",", "level", "=", "logging", ".", "DEBUG", ")", "if", "sendspec", ":", "ca...
Does not return until all background commands are completed.
[ "Does", "not", "return", "until", "all", "background", "commands", "are", "completed", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L271-L299
8,369
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.expect
def expect(self, expect, searchwindowsize=None, maxread=None, timeout=None, iteration_n=1): """Handle child expects, with EOF and TIMEOUT handled iteration_n - Number of times this expect has been called for the send. If 1, (the default) t...
python
def expect(self, expect, searchwindowsize=None, maxread=None, timeout=None, iteration_n=1): """Handle child expects, with EOF and TIMEOUT handled iteration_n - Number of times this expect has been called for the send. If 1, (the default) t...
[ "def", "expect", "(", "self", ",", "expect", ",", "searchwindowsize", "=", "None", ",", "maxread", "=", "None", ",", "timeout", "=", "None", ",", "iteration_n", "=", "1", ")", ":", "if", "isinstance", "(", "expect", ",", "str", ")", ":", "expect", "=...
Handle child expects, with EOF and TIMEOUT handled iteration_n - Number of times this expect has been called for the send. If 1, (the default) then it gets added to the pane of output (if applicable to this run)
[ "Handle", "child", "expects", "with", "EOF", "and", "TIMEOUT", "handled" ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L585-L627
8,370
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.replace_container
def replace_container(self, new_target_image_name, go_home=None): """Replaces a container. Assumes we are in Docker context. """ shutit = self.shutit shutit.log('Replacing container with ' + new_target_image_name + ', please wait...', level=logging.DEBUG) shutit.log(shutit.print_session_state(), level=logging...
python
def replace_container(self, new_target_image_name, go_home=None): """Replaces a container. Assumes we are in Docker context. """ shutit = self.shutit shutit.log('Replacing container with ' + new_target_image_name + ', please wait...', level=logging.DEBUG) shutit.log(shutit.print_session_state(), level=logging...
[ "def", "replace_container", "(", "self", ",", "new_target_image_name", ",", "go_home", "=", "None", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "log", "(", "'Replacing container with '", "+", "new_target_image_name", "+", "', please wait...'", "...
Replaces a container. Assumes we are in Docker context.
[ "Replaces", "a", "container", ".", "Assumes", "we", "are", "in", "Docker", "context", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L630-L668
8,371
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.whoami
def whoami(self, note=None, loglevel=logging.DEBUG): """Returns the current user by executing "whoami". @param note: See send() @return: the output of "whoami" @rtype: string """ shutit = self.shutit shutit.handle_note(note) res = self.send_and_get_output(' command whoami',...
python
def whoami(self, note=None, loglevel=logging.DEBUG): """Returns the current user by executing "whoami". @param note: See send() @return: the output of "whoami" @rtype: string """ shutit = self.shutit shutit.handle_note(note) res = self.send_and_get_output(' command whoami',...
[ "def", "whoami", "(", "self", ",", "note", "=", "None", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "handle_note", "(", "note", ")", "res", "=", "self", ".", "send_and_get_output", "(", ...
Returns the current user by executing "whoami". @param note: See send() @return: the output of "whoami" @rtype: string
[ "Returns", "the", "current", "user", "by", "executing", "whoami", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L671-L691
8,372
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.check_last_exit_values
def check_last_exit_values(self, send, check_exit=True, expect=None, exit_values=None, retry=0, retbool=False): """Internal function to check the exit...
python
def check_last_exit_values(self, send, check_exit=True, expect=None, exit_values=None, retry=0, retbool=False): """Internal function to check the exit...
[ "def", "check_last_exit_values", "(", "self", ",", "send", ",", "check_exit", "=", "True", ",", "expect", "=", "None", ",", "exit_values", "=", "None", ",", "retry", "=", "0", ",", "retbool", "=", "False", ")", ":", "shutit", "=", "self", ".", "shutit"...
Internal function to check the exit value of the shell. Do not use.
[ "Internal", "function", "to", "check", "the", "exit", "value", "of", "the", "shell", ".", "Do", "not", "use", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L695-L739
8,373
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.get_file_perms
def get_file_perms(self, filename, note=None, loglevel=logging.DEBUG): """Returns the permissions of the file on the target as an octal string triplet. @param filename: Filename to get permissions of. @param note: See send() @type filename: ...
python
def get_file_perms(self, filename, note=None, loglevel=logging.DEBUG): """Returns the permissions of the file on the target as an octal string triplet. @param filename: Filename to get permissions of. @param note: See send() @type filename: ...
[ "def", "get_file_perms", "(", "self", ",", "filename", ",", "note", "=", "None", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "handle_note", "(", "note", ")", "cmd", "=", "' command stat -c...
Returns the permissions of the file on the target as an octal string triplet. @param filename: Filename to get permissions of. @param note: See send() @type filename: string @rtype: string
[ "Returns", "the", "permissions", "of", "the", "file", "on", "the", "target", "as", "an", "octal", "string", "triplet", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L956-L981
8,374
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.is_user_id_available
def is_user_id_available(self, user_id, note=None, loglevel=logging.DEBUG): """Determine whether the specified user_id available. @param user_id: User id to be checked. @param note: See send() @type user_id: integer @rtype...
python
def is_user_id_available(self, user_id, note=None, loglevel=logging.DEBUG): """Determine whether the specified user_id available. @param user_id: User id to be checked. @param note: See send() @type user_id: integer @rtype...
[ "def", "is_user_id_available", "(", "self", ",", "user_id", ",", "note", "=", "None", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "handle_note", "(", "note", ")", "# v the space is intentional...
Determine whether the specified user_id available. @param user_id: User id to be checked. @param note: See send() @type user_id: integer @rtype: boolean @return: True is the specified user id is not used yet, False if it's already been assigned to a user.
[ "Determine", "whether", "the", "specified", "user_id", "available", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L1011-L1037
8,375
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.lsb_release
def lsb_release(self, loglevel=logging.DEBUG): """Get distro information from lsb_release. """ # v the space is intentional, to avoid polluting bash history. shutit = self.shutit d = {} self.send(ShutItSendSpec(self, send=' command lsb_release -a', ...
python
def lsb_release(self, loglevel=logging.DEBUG): """Get distro information from lsb_release. """ # v the space is intentional, to avoid polluting bash history. shutit = self.shutit d = {} self.send(ShutItSendSpec(self, send=' command lsb_release -a', ...
[ "def", "lsb_release", "(", "self", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "# v the space is intentional, to avoid polluting bash history.", "shutit", "=", "self", ".", "shutit", "d", "=", "{", "}", "self", ".", "send", "(", "ShutItSendSp...
Get distro information from lsb_release.
[ "Get", "distro", "information", "from", "lsb_release", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L1115-L1142
8,376
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.user_exists
def user_exists(self, user, note=None, loglevel=logging.DEBUG): """Returns true if the specified username exists. @param user: username to check for @param note: See send() @type user: string @rtype: boolean """ shutit = self.shutit shu...
python
def user_exists(self, user, note=None, loglevel=logging.DEBUG): """Returns true if the specified username exists. @param user: username to check for @param note: See send() @type user: string @rtype: boolean """ shutit = self.shutit shu...
[ "def", "user_exists", "(", "self", ",", "user", ",", "note", "=", "None", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "handle_note", "(", "note", ")", "exists", "=", "False", "if", "us...
Returns true if the specified username exists. @param user: username to check for @param note: See send() @type user: string @rtype: boolean
[ "Returns", "true", "if", "the", "specified", "username", "exists", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L1228-L1259
8,377
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession.quick_send
def quick_send(self, send, echo=None, loglevel=logging.INFO): """Quick and dirty send that ignores background tasks. Intended for internal use. """ shutit = self.shutit shutit.log('Quick send: ' + send, level=loglevel) res = self.sendline(ShutItSendSpec(self, send=send, ...
python
def quick_send(self, send, echo=None, loglevel=logging.INFO): """Quick and dirty send that ignores background tasks. Intended for internal use. """ shutit = self.shutit shutit.log('Quick send: ' + send, level=loglevel) res = self.sendline(ShutItSendSpec(self, send=send, ...
[ "def", "quick_send", "(", "self", ",", "send", ",", "echo", "=", "None", ",", "loglevel", "=", "logging", ".", "INFO", ")", ":", "shutit", "=", "self", ".", "shutit", "shutit", ".", "log", "(", "'Quick send: '", "+", "send", ",", "level", "=", "logle...
Quick and dirty send that ignores background tasks. Intended for internal use.
[ "Quick", "and", "dirty", "send", "that", "ignores", "background", "tasks", ".", "Intended", "for", "internal", "use", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L2938-L2951
8,378
ianmiell/shutit
shutit_pexpect.py
ShutItPexpectSession._create_command_file
def _create_command_file(self, expect, send): """Internal function. Do not use. Takes a long command, and puts it in an executable file ready to run. Returns the filename. """ shutit = self.shutit random_id = shutit_util.random_id() fname = shutit_global.shutit_global_object.shutit_state_dir + '/tmp_' + ra...
python
def _create_command_file(self, expect, send): """Internal function. Do not use. Takes a long command, and puts it in an executable file ready to run. Returns the filename. """ shutit = self.shutit random_id = shutit_util.random_id() fname = shutit_global.shutit_global_object.shutit_state_dir + '/tmp_' + ra...
[ "def", "_create_command_file", "(", "self", ",", "expect", ",", "send", ")", ":", "shutit", "=", "self", ".", "shutit", "random_id", "=", "shutit_util", ".", "random_id", "(", ")", "fname", "=", "shutit_global", ".", "shutit_global_object", ".", "shutit_state_...
Internal function. Do not use. Takes a long command, and puts it in an executable file ready to run. Returns the filename.
[ "Internal", "function", ".", "Do", "not", "use", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_pexpect.py#L3535-L3561
8,379
ianmiell/shutit
shutit_class.py
check_dependee_order
def check_dependee_order(depender, dependee, dependee_id): """Checks whether run orders are in the appropriate order. """ # If it depends on a module id, then the module id should be higher up # in the run order. shutit_global.shutit_global_object.yield_to_draw() if dependee.run_order > depender.run_order: retu...
python
def check_dependee_order(depender, dependee, dependee_id): """Checks whether run orders are in the appropriate order. """ # If it depends on a module id, then the module id should be higher up # in the run order. shutit_global.shutit_global_object.yield_to_draw() if dependee.run_order > depender.run_order: retu...
[ "def", "check_dependee_order", "(", "depender", ",", "dependee", ",", "dependee_id", ")", ":", "# If it depends on a module id, then the module id should be higher up", "# in the run order.", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "if", ...
Checks whether run orders are in the appropriate order.
[ "Checks", "whether", "run", "orders", "are", "in", "the", "appropriate", "order", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L4869-L4877
8,380
ianmiell/shutit
shutit_class.py
make_dep_graph
def make_dep_graph(depender): """Returns a digraph string fragment based on the passed-in module """ shutit_global.shutit_global_object.yield_to_draw() digraph = '' for dependee_id in depender.depends_on: digraph = (digraph + '"' + depender.module_id + '"->"' + dependee_id + '";\n') return digraph
python
def make_dep_graph(depender): """Returns a digraph string fragment based on the passed-in module """ shutit_global.shutit_global_object.yield_to_draw() digraph = '' for dependee_id in depender.depends_on: digraph = (digraph + '"' + depender.module_id + '"->"' + dependee_id + '";\n') return digraph
[ "def", "make_dep_graph", "(", "depender", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "digraph", "=", "''", "for", "dependee_id", "in", "depender", ".", "depends_on", ":", "digraph", "=", "(", "digraph", "+", "'\"'",...
Returns a digraph string fragment based on the passed-in module
[ "Returns", "a", "digraph", "string", "fragment", "based", "on", "the", "passed", "-", "in", "module" ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L4880-L4887
8,381
ianmiell/shutit
shutit_class.py
LayerConfigParser.get_config_set
def get_config_set(self, section, option): """Returns a set with each value per config file in it. """ values = set() for cp, filename, fp in self.layers: filename = filename # pylint fp = fp # pylint if cp.has_option(section, option): values.add(cp.get(section, option)) return values
python
def get_config_set(self, section, option): """Returns a set with each value per config file in it. """ values = set() for cp, filename, fp in self.layers: filename = filename # pylint fp = fp # pylint if cp.has_option(section, option): values.add(cp.get(section, option)) return values
[ "def", "get_config_set", "(", "self", ",", "section", ",", "option", ")", ":", "values", "=", "set", "(", ")", "for", "cp", ",", "filename", ",", "fp", "in", "self", ".", "layers", ":", "filename", "=", "filename", "# pylint", "fp", "=", "fp", "# pyl...
Returns a set with each value per config file in it.
[ "Returns", "a", "set", "with", "each", "value", "per", "config", "file", "in", "it", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L117-L126
8,382
ianmiell/shutit
shutit_class.py
LayerConfigParser.reload
def reload(self): """ Re-reads all layers again. In theory this should overwrite all the old values with any newer ones. It assumes we never delete a config item before reload. """ oldlayers = self.layers self.layers = [] for cp, filename, fp in oldlayers: cp = cp # pylint if fp is None: self....
python
def reload(self): """ Re-reads all layers again. In theory this should overwrite all the old values with any newer ones. It assumes we never delete a config item before reload. """ oldlayers = self.layers self.layers = [] for cp, filename, fp in oldlayers: cp = cp # pylint if fp is None: self....
[ "def", "reload", "(", "self", ")", ":", "oldlayers", "=", "self", ".", "layers", "self", ".", "layers", "=", "[", "]", "for", "cp", ",", "filename", ",", "fp", "in", "oldlayers", ":", "cp", "=", "cp", "# pylint", "if", "fp", "is", "None", ":", "s...
Re-reads all layers again. In theory this should overwrite all the old values with any newer ones. It assumes we never delete a config item before reload.
[ "Re", "-", "reads", "all", "layers", "again", ".", "In", "theory", "this", "should", "overwrite", "all", "the", "old", "values", "with", "any", "newer", "ones", ".", "It", "assumes", "we", "never", "delete", "a", "config", "item", "before", "reload", "."...
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L128-L141
8,383
ianmiell/shutit
shutit_class.py
ShutIt.get_shutit_pexpect_session_environment
def get_shutit_pexpect_session_environment(self, environment_id): """Returns the first shutit_pexpect_session object related to the given environment-id """ if not isinstance(environment_id, str): self.fail('Wrong argument type in get_shutit_pexpect_session_environment') # pragma: no cover for env in shuti...
python
def get_shutit_pexpect_session_environment(self, environment_id): """Returns the first shutit_pexpect_session object related to the given environment-id """ if not isinstance(environment_id, str): self.fail('Wrong argument type in get_shutit_pexpect_session_environment') # pragma: no cover for env in shuti...
[ "def", "get_shutit_pexpect_session_environment", "(", "self", ",", "environment_id", ")", ":", "if", "not", "isinstance", "(", "environment_id", ",", "str", ")", ":", "self", ".", "fail", "(", "'Wrong argument type in get_shutit_pexpect_session_environment'", ")", "# pr...
Returns the first shutit_pexpect_session object related to the given environment-id
[ "Returns", "the", "first", "shutit_pexpect_session", "object", "related", "to", "the", "given", "environment", "-", "id" ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L515-L524
8,384
ianmiell/shutit
shutit_class.py
ShutIt.get_current_shutit_pexpect_session_environment
def get_current_shutit_pexpect_session_environment(self, note=None): """Returns the current environment from the currently-set default pexpect child. """ self.handle_note(note) current_session = self.get_current_shutit_pexpect_session() if current_session is not None: res = current_session.current_enviro...
python
def get_current_shutit_pexpect_session_environment(self, note=None): """Returns the current environment from the currently-set default pexpect child. """ self.handle_note(note) current_session = self.get_current_shutit_pexpect_session() if current_session is not None: res = current_session.current_enviro...
[ "def", "get_current_shutit_pexpect_session_environment", "(", "self", ",", "note", "=", "None", ")", ":", "self", ".", "handle_note", "(", "note", ")", "current_session", "=", "self", ".", "get_current_shutit_pexpect_session", "(", ")", "if", "current_session", "is"...
Returns the current environment from the currently-set default pexpect child.
[ "Returns", "the", "current", "environment", "from", "the", "currently", "-", "set", "default", "pexpect", "child", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L527-L538
8,385
ianmiell/shutit
shutit_class.py
ShutIt.get_current_shutit_pexpect_session
def get_current_shutit_pexpect_session(self, note=None): """Returns the currently-set default pexpect child. @return: default shutit pexpect child object """ self.handle_note(note) res = self.current_shutit_pexpect_session self.handle_note_after(note) return res
python
def get_current_shutit_pexpect_session(self, note=None): """Returns the currently-set default pexpect child. @return: default shutit pexpect child object """ self.handle_note(note) res = self.current_shutit_pexpect_session self.handle_note_after(note) return res
[ "def", "get_current_shutit_pexpect_session", "(", "self", ",", "note", "=", "None", ")", ":", "self", ".", "handle_note", "(", "note", ")", "res", "=", "self", ".", "current_shutit_pexpect_session", "self", ".", "handle_note_after", "(", "note", ")", "return", ...
Returns the currently-set default pexpect child. @return: default shutit pexpect child object
[ "Returns", "the", "currently", "-", "set", "default", "pexpect", "child", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L541-L549
8,386
ianmiell/shutit
shutit_class.py
ShutIt.get_shutit_pexpect_sessions
def get_shutit_pexpect_sessions(self, note=None): """Returns all the shutit_pexpect_session keys for this object. @return: list of all shutit_pexpect_session keys (pexpect_session_ids) """ self.handle_note(note) sessions = [] for key in self.shutit_pexpect_sessions: sessions.append(shutit_object.shutit_...
python
def get_shutit_pexpect_sessions(self, note=None): """Returns all the shutit_pexpect_session keys for this object. @return: list of all shutit_pexpect_session keys (pexpect_session_ids) """ self.handle_note(note) sessions = [] for key in self.shutit_pexpect_sessions: sessions.append(shutit_object.shutit_...
[ "def", "get_shutit_pexpect_sessions", "(", "self", ",", "note", "=", "None", ")", ":", "self", ".", "handle_note", "(", "note", ")", "sessions", "=", "[", "]", "for", "key", "in", "self", ".", "shutit_pexpect_sessions", ":", "sessions", ".", "append", "(",...
Returns all the shutit_pexpect_session keys for this object. @return: list of all shutit_pexpect_session keys (pexpect_session_ids)
[ "Returns", "all", "the", "shutit_pexpect_session", "keys", "for", "this", "object", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L552-L562
8,387
ianmiell/shutit
shutit_class.py
ShutIt.set_default_shutit_pexpect_session
def set_default_shutit_pexpect_session(self, shutit_pexpect_session): """Sets the default pexpect child. @param shutit_pexpect_session: pexpect child to set as default """ assert isinstance(shutit_pexpect_session, ShutItPexpectSession), shutit_util.print_debug() self.current_shutit_pexpect_session = shutit_p...
python
def set_default_shutit_pexpect_session(self, shutit_pexpect_session): """Sets the default pexpect child. @param shutit_pexpect_session: pexpect child to set as default """ assert isinstance(shutit_pexpect_session, ShutItPexpectSession), shutit_util.print_debug() self.current_shutit_pexpect_session = shutit_p...
[ "def", "set_default_shutit_pexpect_session", "(", "self", ",", "shutit_pexpect_session", ")", ":", "assert", "isinstance", "(", "shutit_pexpect_session", ",", "ShutItPexpectSession", ")", ",", "shutit_util", ".", "print_debug", "(", ")", "self", ".", "current_shutit_pex...
Sets the default pexpect child. @param shutit_pexpect_session: pexpect child to set as default
[ "Sets", "the", "default", "pexpect", "child", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L582-L589
8,388
ianmiell/shutit
shutit_class.py
ShutIt.fail
def fail(self, msg, shutit_pexpect_child=None, throw_exception=False): """Handles a failure, pausing if a pexpect child object is passed in. @param shutit_pexpect_child: pexpect child to work on @param throw_exception: Whether to throw an exception. @type throw_exception: boolean """ shutit_global.shutit_g...
python
def fail(self, msg, shutit_pexpect_child=None, throw_exception=False): """Handles a failure, pausing if a pexpect child object is passed in. @param shutit_pexpect_child: pexpect child to work on @param throw_exception: Whether to throw an exception. @type throw_exception: boolean """ shutit_global.shutit_g...
[ "def", "fail", "(", "self", ",", "msg", ",", "shutit_pexpect_child", "=", "None", ",", "throw_exception", "=", "False", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "# Note: we must not default to a child here", "if", "shut...
Handles a failure, pausing if a pexpect child object is passed in. @param shutit_pexpect_child: pexpect child to work on @param throw_exception: Whether to throw an exception. @type throw_exception: boolean
[ "Handles", "a", "failure", "pausing", "if", "a", "pexpect", "child", "object", "is", "passed", "in", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L607-L629
8,389
ianmiell/shutit
shutit_class.py
ShutIt.get_current_environment
def get_current_environment(self, note=None): """Returns the current environment id from the current shutit_pexpect_session """ shutit_global.shutit_global_object.yield_to_draw() self.handle_note(note) res = self.get_current_shutit_pexpect_session_environment().environment_id self.handle_note_after(note) ...
python
def get_current_environment(self, note=None): """Returns the current environment id from the current shutit_pexpect_session """ shutit_global.shutit_global_object.yield_to_draw() self.handle_note(note) res = self.get_current_shutit_pexpect_session_environment().environment_id self.handle_note_after(note) ...
[ "def", "get_current_environment", "(", "self", ",", "note", "=", "None", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "self", ".", "handle_note", "(", "note", ")", "res", "=", "self", ".", "get_current_shutit_pexpect_se...
Returns the current environment id from the current shutit_pexpect_session
[ "Returns", "the", "current", "environment", "id", "from", "the", "current", "shutit_pexpect_session" ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L632-L640
8,390
ianmiell/shutit
shutit_class.py
ShutIt.handle_note
def handle_note(self, note, command='', training_input=''): """Handle notes and walkthrough option. @param note: See send() """ shutit_global.shutit_global_object.yield_to_draw() if self.build['walkthrough'] and note != None and note != '': assert isinstance(note, str), shutit_util.print_d...
python
def handle_note(self, note, command='', training_input=''): """Handle notes and walkthrough option. @param note: See send() """ shutit_global.shutit_global_object.yield_to_draw() if self.build['walkthrough'] and note != None and note != '': assert isinstance(note, str), shutit_util.print_d...
[ "def", "handle_note", "(", "self", ",", "note", ",", "command", "=", "''", ",", "training_input", "=", "''", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "if", "self", ".", "build", "[", "'walkthrough'", "]", "and...
Handle notes and walkthrough option. @param note: See send()
[ "Handle", "notes", "and", "walkthrough", "option", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L938-L964
8,391
ianmiell/shutit
shutit_class.py
ShutIt.expect_allow_interrupt
def expect_allow_interrupt(self, shutit_pexpect_child, expect, timeout, iteration_s=1): """This function allows you to interrupt the run at more or less any point by breaking up the timeout into interacti...
python
def expect_allow_interrupt(self, shutit_pexpect_child, expect, timeout, iteration_s=1): """This function allows you to interrupt the run at more or less any point by breaking up the timeout into interacti...
[ "def", "expect_allow_interrupt", "(", "self", ",", "shutit_pexpect_child", ",", "expect", ",", "timeout", ",", "iteration_s", "=", "1", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "shutit_pexpect_session", "=", "self", "...
This function allows you to interrupt the run at more or less any point by breaking up the timeout into interactive chunks.
[ "This", "function", "allows", "you", "to", "interrupt", "the", "run", "at", "more", "or", "less", "any", "point", "by", "breaking", "up", "the", "timeout", "into", "interactive", "chunks", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L978-L1030
8,392
ianmiell/shutit
shutit_class.py
ShutIt.send_host_file
def send_host_file(self, path, hostfilepath, expect=None, shutit_pexpect_child=None, note=None, user=None, group=None, loglevel=logging.INFO): """Send file fr...
python
def send_host_file(self, path, hostfilepath, expect=None, shutit_pexpect_child=None, note=None, user=None, group=None, loglevel=logging.INFO): """Send file fr...
[ "def", "send_host_file", "(", "self", ",", "path", ",", "hostfilepath", ",", "expect", "=", "None", ",", "shutit_pexpect_child", "=", "None", ",", "note", "=", "None", ",", "user", "=", "None", ",", "group", "=", "None", ",", "loglevel", "=", "logging", ...
Send file from host machine to given path @param path: Path to send file to. @param hostfilepath: Path to file from host to send to target. @param expect: See send() @param shutit_pexpect_child: See send() @param note: See send() @param user: Set ownership to this...
[ "Send", "file", "from", "host", "machine", "to", "given", "path" ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1118-L1168
8,393
ianmiell/shutit
shutit_class.py
ShutIt.send_host_dir
def send_host_dir(self, path, hostfilepath, expect=None, shutit_pexpect_child=None, note=None, user=None, group=None, loglevel=logging.DEBUG): """Send directory and a...
python
def send_host_dir(self, path, hostfilepath, expect=None, shutit_pexpect_child=None, note=None, user=None, group=None, loglevel=logging.DEBUG): """Send directory and a...
[ "def", "send_host_dir", "(", "self", ",", "path", ",", "hostfilepath", ",", "expect", "=", "None", ",", "shutit_pexpect_child", "=", "None", ",", "note", "=", "None", ",", "user", "=", "None", ",", "group", "=", "None", ",", "loglevel", "=", "logging", ...
Send directory and all contents recursively from host machine to given path. It will automatically make directories on the target. @param path: Path to send directory to (places hostfilepath inside path as a subfolder) @param hostfilepath: Path to file from host to send to target @param expect: ...
[ "Send", "directory", "and", "all", "contents", "recursively", "from", "host", "machine", "to", "given", "path", ".", "It", "will", "automatically", "make", "directories", "on", "the", "target", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1171-L1250
8,394
ianmiell/shutit
shutit_class.py
ShutIt.delete_text
def delete_text(self, text, fname, pattern=None, expect=None, shutit_pexpect_child=None, note=None, before=False, force=False, line_oriented=True, log...
python
def delete_text(self, text, fname, pattern=None, expect=None, shutit_pexpect_child=None, note=None, before=False, force=False, line_oriented=True, log...
[ "def", "delete_text", "(", "self", ",", "text", ",", "fname", ",", "pattern", "=", "None", ",", "expect", "=", "None", ",", "shutit_pexpect_child", "=", "None", ",", "note", "=", "None", ",", "before", "=", "False", ",", "force", "=", "False", ",", "...
Delete a chunk of text from a file. See insert_text.
[ "Delete", "a", "chunk", "of", "text", "from", "a", "file", ".", "See", "insert_text", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1422-L1447
8,395
ianmiell/shutit
shutit_class.py
ShutIt.get_file
def get_file(self, target_path, host_path, note=None, loglevel=logging.DEBUG): """Copy a file from the target machine to the host machine @param target_path: path to file in the target @param host_path: path to file on the host machine (e.g. copy test) ...
python
def get_file(self, target_path, host_path, note=None, loglevel=logging.DEBUG): """Copy a file from the target machine to the host machine @param target_path: path to file in the target @param host_path: path to file on the host machine (e.g. copy test) ...
[ "def", "get_file", "(", "self", ",", "target_path", ",", "host_path", ",", "note", "=", "None", ",", "loglevel", "=", "logging", ".", "DEBUG", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "self", ".", "handle_note",...
Copy a file from the target machine to the host machine @param target_path: path to file in the target @param host_path: path to file on the host machine (e.g. copy test) @param note: See send() @type target_path: string @type host_path: string @return: boolean @rtype: s...
[ "Copy", "a", "file", "from", "the", "target", "machine", "to", "the", "host", "machine" ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1673-L1707
8,396
ianmiell/shutit
shutit_class.py
ShutIt.prompt_cfg
def prompt_cfg(self, msg, sec, name, ispass=False): """Prompt for a config value, optionally saving it to the user-level cfg. Only runs if we are in an interactive mode. @param msg: Message to display to user. @param sec: Section of config to add to. @param name: Config item name. @param ispass: If...
python
def prompt_cfg(self, msg, sec, name, ispass=False): """Prompt for a config value, optionally saving it to the user-level cfg. Only runs if we are in an interactive mode. @param msg: Message to display to user. @param sec: Section of config to add to. @param name: Config item name. @param ispass: If...
[ "def", "prompt_cfg", "(", "self", ",", "msg", ",", "sec", ",", "name", ",", "ispass", "=", "False", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_draw", "(", ")", "cfgstr", "=", "'[%s]/%s'", "%", "(", "sec", ",", "name", ")", "...
Prompt for a config value, optionally saving it to the user-level cfg. Only runs if we are in an interactive mode. @param msg: Message to display to user. @param sec: Section of config to add to. @param name: Config item name. @param ispass: If True, hide the input from the terminal. ...
[ "Prompt", "for", "a", "config", "value", "optionally", "saving", "it", "to", "the", "user", "-", "level", "cfg", ".", "Only", "runs", "if", "we", "are", "in", "an", "interactive", "mode", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1710-L1782
8,397
ianmiell/shutit
shutit_class.py
ShutIt.step_through
def step_through(self, msg='', shutit_pexpect_child=None, level=1, print_input=True, value=True): """Implements a step-through function, using pause_point. """ shutit_global.shutit_global_object.yield_to_draw() shutit_pexpect_child = shutit_pexpect_child or self.get_current_shutit_pexpect_session().pexpect_chil...
python
def step_through(self, msg='', shutit_pexpect_child=None, level=1, print_input=True, value=True): """Implements a step-through function, using pause_point. """ shutit_global.shutit_global_object.yield_to_draw() shutit_pexpect_child = shutit_pexpect_child or self.get_current_shutit_pexpect_session().pexpect_chil...
[ "def", "step_through", "(", "self", ",", "msg", "=", "''", ",", "shutit_pexpect_child", "=", "None", ",", "level", "=", "1", ",", "print_input", "=", "True", ",", "value", "=", "True", ")", ":", "shutit_global", ".", "shutit_global_object", ".", "yield_to_...
Implements a step-through function, using pause_point.
[ "Implements", "a", "step", "-", "through", "function", "using", "pause_point", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1785-L1796
8,398
ianmiell/shutit
shutit_class.py
ShutIt.interact
def interact(self, msg='SHUTIT PAUSE POINT', shutit_pexpect_child=None, print_input=True, level=1, resize=True, color='32', default_msg=None, wait=-1): """Same as pause_point, but sets up the terminal ready for unm...
python
def interact(self, msg='SHUTIT PAUSE POINT', shutit_pexpect_child=None, print_input=True, level=1, resize=True, color='32', default_msg=None, wait=-1): """Same as pause_point, but sets up the terminal ready for unm...
[ "def", "interact", "(", "self", ",", "msg", "=", "'SHUTIT PAUSE POINT'", ",", "shutit_pexpect_child", "=", "None", ",", "print_input", "=", "True", ",", "level", "=", "1", ",", "resize", "=", "True", ",", "color", "=", "'32'", ",", "default_msg", "=", "N...
Same as pause_point, but sets up the terminal ready for unmediated interaction.
[ "Same", "as", "pause_point", "but", "sets", "up", "the", "terminal", "ready", "for", "unmediated", "interaction", "." ]
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1799-L1819
8,399
ianmiell/shutit
shutit_class.py
ShutIt.pause_point
def pause_point(self, msg='SHUTIT PAUSE POINT', shutit_pexpect_child=None, print_input=True, level=1, resize=True, color='32', default_msg=None, interact=False, wait=-...
python
def pause_point(self, msg='SHUTIT PAUSE POINT', shutit_pexpect_child=None, print_input=True, level=1, resize=True, color='32', default_msg=None, interact=False, wait=-...
[ "def", "pause_point", "(", "self", ",", "msg", "=", "'SHUTIT PAUSE POINT'", ",", "shutit_pexpect_child", "=", "None", ",", "print_input", "=", "True", ",", "level", "=", "1", ",", "resize", "=", "True", ",", "color", "=", "'32'", ",", "default_msg", "=", ...
Inserts a pause in the build session, which allows the user to try things out before continuing. Ignored if we are not in an interactive mode, or the interactive level is less than the passed-in one. Designed to help debug the build, or drop to on failure so the situation can be debugged. @param msg: ...
[ "Inserts", "a", "pause", "in", "the", "build", "session", "which", "allows", "the", "user", "to", "try", "things", "out", "before", "continuing", ".", "Ignored", "if", "we", "are", "not", "in", "an", "interactive", "mode", "or", "the", "interactive", "leve...
19cd64cdfb23515b106b40213dccff4101617076
https://github.com/ianmiell/shutit/blob/19cd64cdfb23515b106b40213dccff4101617076/shutit_class.py#L1822-L1891