Example #1
0
 def __bit_already_installed(self, name, version):
     try:
         bit_description = project_descriptor_parser.parse_from(
             f'bits/{name}')
         return bit_description.version == version
     except:
         return False
Example #2
0
 def install(self, name, version):
     if self.__bit_already_installed(name, version):
         print(f'cpm: bit already installed: {name}:{version}')
         return
     project_description = project_descriptor_parser.parse_from('.')
     self._log_install_or_upgrade(project_description, name, version)
     bit_download = self.cpm_hub_connector.download_bit(name, version)
     self.bit_installer.install(bit_download)
Example #3
0
 def load(self, directory):
     project_descriptor = project_descriptor_parser.parse_from(directory)
     # TODO: Target specific bits
     self.parse_build_bit_descriptors(project_descriptor.build.bits,
                                      project_descriptor.build.declared_bits,
                                      lambda description: description.build.declared_bits)
     self.parse_build_bit_descriptors(project_descriptor.test.bits,
                                      project_descriptor.test.declared_bits,
                                      lambda description: description.test.declared_bits)
     return project_composer.compose(project_descriptor)
Example #4
0
 def load(self, directory, target_name='default'):
     project_descriptor = project_descriptor_parser.parse_from(directory)
     if not target_is_valid(project_descriptor, target_name):
         raise InvalidTarget
     # TODO: Target specific bits
     self.parse_bit_build_descriptors(
         project_descriptor.build.bits,
         project_descriptor.build.declared_bits,
         lambda description: description.build.declared_bits)
     self.parse_bit_build_descriptors(
         project_descriptor.test.bits,
         project_descriptor.test.declared_bits,
         lambda description: description.test.declared_bits)
     return project_composer.compose(project_descriptor, target_name)
Example #5
0
 def parse_bit_build_descriptors(self, bits, declared_bits,
                                 next_declared_bits):
     for declared_bit in declared_bits:
         if declared_bit.name not in bits:
             try:
                 bit_descriptor = project_descriptor_parser.parse_from(
                     f'bits/{declared_bit.name}')
                 bit_descriptor.declared_bit = declared_bit
                 bits[declared_bit.name] = bit_descriptor
                 self.parse_bit_build_descriptors(
                     bits, next_declared_bits(bit_descriptor),
                     next_declared_bits)
             except ProjectDescriptorNotFound:
                 print(
                     f'cpm: warning: bit \'{declared_bit.name}:{declared_bit.version}\' not installed. '
                     f'Run \'cpm install\' to install missing bits.')
Example #6
0
 def __install_recursively(self, directory='.'):
     project_descriptor = project_descriptor_parser.parse_from(directory)
     for declared_bit in project_descriptor.build.declared_bits:
         self.install(declared_bit.name, declared_bit.version)
         self.__install_recursively(f'bits/{declared_bit.name}')
Example #7
0
 def install_all(self, directory='.'):
     self.__install_recursively(directory)
     project_descriptor = project_descriptor_parser.parse_from(directory)
     for declared_bit in project_descriptor.test.declared_bits:
         self.install(declared_bit.name, declared_bit.version)
Example #8
0
 def publish_template(self):
     project_descriptor = project_descriptor_parser.parse_from('.')
     package_name = self.template_packager.pack(project_descriptor, 'dist')
     self.cpm_hub_connector.publish_template(project_descriptor,
                                             package_name)
Example #9
0
 def parse_build_bit_descriptors(self, bits, declared_bits, next_declared_bits):
     for declared_bit in declared_bits:
         if declared_bit.name not in bits:
             bit_descriptor = project_descriptor_parser.parse_from(f'bits/{declared_bit.name}')
             bits[declared_bit.name] = bit_descriptor
             self.parse_build_bit_descriptors(bits, next_declared_bits(bit_descriptor), next_declared_bits)