How to use _write_description method in lisa

Best Python code snippet using lisa_python

gitweb.py

Source:gitweb.py Github

copy

Full Screen

...125 f.flush()126 os.fsync(f.fileno())127 f.close()128 os.rename(tmp, path)129def _write_description(repositories, name, description):130 log = logging.getLogger('gitosis.gitweb.write_description')131 path = os.path.join(132 repositories,133 name,134 'description',135 )136 log.debug('Writing new description file %s' % path)137 tmp = '%s.%d.tmp' % (path, os.getpid())138 f = file(tmp, 'w')139 try:140 print >>f, description141 finally:142 f.flush()143 os.fsync(f.fileno())144 f.close()145 os.rename(tmp, path)146def _generate_user_description_entry(name, repositories, description):147 log = logging.getLogger('gitosis.gitweb._generate_user_description_entry')148 remove = repositories + os.sep149 userpos = -1150 # Deal with wildcards in the path151 if -1 != name.find('$user'):152 namesplit = name.split(os.sep)153 # Work out which of the path components matches '$user' so154 # we can use it later155 for i in range(len(namesplit)):156 if namesplit[i] == '$user':157 userpos = i158 break159 name = name.replace('$user', '*')160 if -1 != name.find('*'):161 for entry in glob.glob(os.path.join(repositories, name)):162 relative = entry.replace(remove, '', 1)163 # Now, if we have a userpos we can use that to work164 # out who owns this repository165 if userpos != -1:166 namesplit = relative.split(os.sep)167 owner = namesplit[userpos]168 try:169 # Let's see if we can get a full name rather170 # than just username here171 pwnam = pwd.getpwnam(owner)172 owner = pwnam[4]173 except:174 pass175 else:176 owner = ""177 new_description = description.replace('$username', owner)178 log.debug('Found entry %s: %s' % (entry, new_description))179 _write_description(repositories, entry, new_description)180def set_descriptions(config):181 """182 Set descriptions for gitweb use.183 """184 log = logging.getLogger('gitosis.gitweb.set_descriptions')185 repositories = util.getRepositoryDir(config)186 for section in config.sections():187 l = section.split(None, 1)188 type_ = l.pop(0)189 if type_ != 'repo':190 continue191 if not l:192 continue193 try:194 description = config.get(section, 'description')195 except (NoSectionError, NoOptionError):196 continue197 if not description:198 continue199 name, = l200 log.debug('looking at name %s' % name)201 # Special handling for $user and wildcard repositories202 if -1 != name.find('$user') or -1 != name.find('*'):203 _generate_user_description_entry(name, repositories, description)204 continue205 if not os.path.exists(os.path.join(repositories, name)):206 namedotgit = '%s.git' % name207 if os.path.exists(os.path.join(repositories, namedotgit)):208 name = namedotgit209 else:210 log.warning(211 'Cannot find %(name)r in %(repositories)r'212 % dict(name=name, repositories=repositories))213 continue...

Full Screen

Full Screen

mkdiri.py

Source:mkdiri.py Github

copy

Full Screen

...22 self.is_file_mode = is_file_mode23 config = Config()24 self.desc_name = config.description_name25 self.file_desc_name = config.file_description_name26 def _write_description(self, desc_path, description):27 """28 Make description file.29 Parameters30 ----------31 desc_path : String32 description file path33 description : String34 description text35 """36 description = description.replace('\\n', '\n')37 with open(desc_path, 'w') as f:38 f.write(description)39 def _write_file_description(self, file_path, description_dict):40 """41 Make file description.42 Parameters43 ----------44 file_path : String45 file description path46 description_dict : Dict47 description Dict(LsiItemLoader.read_file_description)48 """49 keys_list = sorted(list(description_dict.keys()))50 description = ''51 for keys in keys_list:52 desc = description_dict[keys]53 for i in range(len(desc)):54 if desc[len(desc)-1-i]!='\n':55 break56 desc = desc[:len(desc)-i]57 description += '\\/'+keys+'\n'+desc+'\n\n'58 with open(file_path, 'w') as f:59 f.write(description)60 def _mkdiri(self, dir_path, description):61 """62 Make directory and make description file.63 Parameters64 ----------65 dir_path : String66 Directory Path67 description : String68 description text69 """70 dir_path = dir_path+'/' if dir_path[-1] != '/' else dir_path71 if os.path.exists(dir_path):72 if self.is_add_mode:73 self._write_description(dir_path+self.desc_name, description)74 else:75 self._raise_file_exists_error(self.dir_path)76 else:77 os.mkdir(dir_path)78 self._write_description(dir_path+self.desc_name, description)79 def _mkfilei(self, file_path, description):80 """81 Make file description.82 Parameters83 ----------84 file_path : String85 File Path86 description : String87 description text88 """89 split_path = file_path.split('/')90 if len(split_path)==1:91 base_path = './'92 else:...

Full Screen

Full Screen

test_spec_gen.py

Source:test_spec_gen.py Github

copy

Full Screen

...62 file.write(".. class:: ")63 file.write(metadata["name"] + "\n") # Test Suite Name64 file.write(" :noindex:" + "\n")65 file.write("\n")66 _write_description(file, metadata, True) # Description67 file.write(" :platform: ")68 file.write("``" + "Azure, Ready" + "``\n") # Platform69 file.write(" :area: ")70 file.write("``" + metadata["area"] + "``\n") # Area71 file.write(" :category: ")72 file.write("``" + metadata["category"] + "``\n") # Category73 file.write("\n")74def _write_case(file: TextIO, metadata: Dict[str, str]) -> None:75 """76 Writes info of a test case.77 Args:78 file (TextIO): test spec file79 metadata (Dict[str, str]): test case metadata80 """81 file.write(".. _" + metadata["name"] + ":\n") # custom anchor82 file.write("\n")83 file.write(" .. method:: ")84 file.write(metadata["name"] + "\n") # Test Case Name85 file.write(" :noindex:" + "\n")86 file.write("\n")87 file.write(" ") # 1-tab indentation88 _write_description(file, metadata) # Description89 file.write(" :priority: ")90 file.write("``" + str(metadata.get("priority", 2)) + "``\n") # Priority91 if "requirement" in metadata.keys():92 file.write(" :requirement: ")93 file.write("``" + str(metadata["requirement"]) + "``\n") # Requirement94 file.write("\n")95def _write_description(96 file: TextIO, metadata: Dict[str, str], is_suite: bool = False97) -> None:98 """99 Writes the description of a test suite/case.100 Args:101 file (TextIO): test spec file102 metadata (Dict[str, str]): test suite/case metadata103 is_suite (bool): signifies if it's a test suite. Defaults to False.104 """105 file.write(" :description: | ")106 text = metadata["description"].split("\n")107 # filter out empty lines108 res = filter(lambda line: (not line.isspace()) and (not line == ""), text)109 text = list(res)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful