text stringlengths 0 828 |
|---|
"""""" |
if self.exists(): |
with open(self.dot_file, 'r') as handle: |
self.update(json.load(handle)) |
if self.options['context'] is not None: |
self['context'] = self.options['context'] |
else: |
self.options['context'] = self['context'] |
if self.options['defaults'] is not None: |
self['defaults'] = self.options['defaults'] |
else: |
self.options['defaults'] = self['defaults'] |
if self.options['output'] is not None: |
self['output'] = self.options['output'] |
if self.options.get('inclusive', False): |
self['inclusive'] = True |
if self.options.get('exclude', []): |
self['exclude'].extend(self.options['exclude']) |
if self['output'] is None: |
self['output'] = os.path.join(os.getcwd(), 'dockerstache-output') |
self['output_path'] = self.abs_output_dir() |
self['input_path'] = self.abs_input_dir() |
if self['context'] is not None: |
self['context_path'] = absolute_path(self['context']) |
if self['defaults'] is not None: |
self['defaults_path'] = absolute_path(self['defaults'])" |
1545,"def env_dictionary(self): |
"""""" |
convert the options to this script into an |
env var dictionary for pre and post scripts |
"""""" |
none_to_str = lambda x: str(x) if x else """" |
return {""DOCKERSTACHE_{}"".format(k.upper()): none_to_str(v) for k, v in six.iteritems(self)}" |
1546,"def pre_script(self): |
"""""" |
execute the pre script if it is defined |
"""""" |
if self['pre_script'] is None: |
return |
LOGGER.info(""Executing pre script: {}"".format(self['pre_script'])) |
cmd = self['pre_script'] |
execute_command(self.abs_input_dir(), cmd, self.env_dictionary()) |
LOGGER.info(""Pre Script completed"")" |
1547,"def say( |
text = None, |
preference_program = ""festival"", |
background = False, |
silent = True, |
filepath = None |
): |
"""""" |
Say specified text to speakers or to file, as specified. Determine the |
program to use based on the specified program preference and availability, |
then say the text to speakers or synthesize speech of the text and save it |
to file, as specified. |
"""""" |
if not text: |
if not silent: |
print(""text not specified"") |
return False |
# Determine the program to use based on program preference and program |
# availability. |
preference_order_programs = [ |
""festival"", |
""espeak"", |
""pico2wave"", |
""deep_throat.py"" |
] |
# Remove the specified preference program from the default program |
# preferences order and prioritise it. |
preference_order_programs.remove(preference_program) |
preference_order_programs.insert(0, preference_program) |
# Determine first program that is available in the programs order of |
# preference. |
preference_order_programs_available =\ |
[program for program in preference_order_programs \ |
if shijian.which(program) is not None] |
if not preference_order_programs_available: |
if not silent: |
print(""text-to-speech program unavailable"") |
return False |
program = preference_order_programs_available[0] |
if program != preference_program and not silent: |
print(""text-to-speech preference program unavailable, using {program}"".format(program = program)) |
if program == ""festival"": |
if not filepath: |
command = """""" |
echo ""{text}"" | festival --tts |
"""""".format(text = text) |
else: |
command = """""" |
echo ""{text}"" | text2wave -o {filepath} |
"""""".format(text = text, filepath = filepath) |
elif program == ""espeak"": |
if not filepath: |
command = """""" |
echo ""{text}"" | espeak |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.