text:
using System;
class NumeralSystems
{
    static void Main()
    {
        byte[] BinNummber = new byte[16];
        Console.Write("From which type nummber you want to convert 2, 10, 16: ");
        byte index = byte.Parse(Console.ReadLine());
        if (index == 10)
        {
            Console.WriteLine("Enter decimal positively Integer and program will convert it!");
            Console.Write("n=");
            uint n = uint.Parse(Console.ReadLine());
            Console.WriteLine("Your nummber in binary is: {0}",DecimalToBinary.Convert(n));
            Console.WriteLine("Your nummber in hexadecimal is: {0}",DecimalToHexidemical.Convert(n));

        }

        if (index == 2)
        {
            Console.WriteLine("Enter binary positively Integer and program will convert it!");
            for (int i = 0; i < 15; i++)
            {
                Console.Write("n[{0}]=",i);
                BinNummber[i] = byte.Parse(Console.ReadLine());
            }
            Console.WriteLine("Your nummber in decimal is: {0}",BinaryToDecimal.Convert(BinNummber));
            Console.WriteLine("Your nummber in hexmila is: {0}" );

        }

            Console.ReadLine();
    }
}


text:
Tutorial 4 注解式分布式静态配置文件和静态配置项(最佳实践)
===========================================================

配置类
------

定义
~~~~

::

    package com.example.disconf.demo.config;

    import com.baidu.disconf.client.common.annotations.DisconfFile;
    import com.baidu.disconf.client.common.annotations.DisconfFileItem;

    /**
     * 静态 配置文件 示例
     *
     * @author liaoqiqi
     * @version 2014-6-17
     */
    @DisconfFile(filename = "static.properties")
    public class StaticConfig {

        private static int staticVar;

        @DisconfFileItem(name = "staticVar", associateField = "staticVar")
        public static int getStaticVar() {
            return staticVar;
        }

        public static void setStaticVar(int staticVar) {
            StaticConfig.staticVar = staticVar;
        }

    }

使用
~~~~

::

    package com.example.disconf.demo.service;

    import com.baidu.disconf.client.common.annotations.DisconfItem;
    import com.example.disconf.demo.config.StaticConfig;

    /**
     * 使用静态配置文件的示例

     * Plus

     * 静态配置项 使用示例
     *
     * @author liaoqiqi
     * @version 2014-8-14
     */
    public class SimpleStaticService {

        private static int staticItem = 56;

        /**
         *
         * @return
         */
        public static int getStaticFileData() {

            return StaticConfig.getStaticVar();
        }
    }

和

::

    LOGGER.info("static file data:"
                            + SimpleStaticService.getStaticFileData());

配置项
------

定义
~~~~

::

    package com.example.disconf.demo.service;

    import com.baidu.disconf.client.common.annotations.DisconfItem;
    import com.example.disconf.demo.config.StaticConfig;

    /**
     * 使用静态配置文件的示例

     * Plus

     * 静态配置项 使用示例
     *
     * @author liaoqiqi
     * @version 2014-8-14
     */
    public class SimpleStaticService {

        private static int staticItem = 56;

        /**
         *
         * @return
         */
        public static int getStaticFileData() {

            return StaticConfig.getStaticVar();
        }

        @DisconfItem(key = "staticItem")
        public static int getStaticItem() {
            return staticItem;
        }

        public static void setStaticItem(int staticItem) {
            SimpleStaticService.staticItem = staticItem;
        }
    }

使用
~~~~

::

    LOGGER.info("static item data:"
                        + SimpleStaticService.getStaticItem());

redpajama_set_name: RedPajamaGithub


text:
import traceback
import os
import random
# import json
import subprocess
import zipfile
import zlib

from datetime import datetime as dt

from tg import request, config

from rpac.model import *

__all__ = [
    'gen_pdf',
    'null_string_sizes',
    'format_fibers',
    'format_cares',
    'format_coo',
    'format_list']

CARES = [
    "WASH",
    "BLEACH",
    "IRON",
    "DRY",
    "DRYCLEAN",
    "SPECIALCARE"
]

def gen_pdf(header_no, details):
    try:
        public_dir = config.get( 'public_dir' )
        download_dir = os.path.join( public_dir, 'layout_pdf' )
        if not os.path.exists( download_dir ):
            os.makedirs( download_dir )

        phantomjs = os.path.join( public_dir, 'phantomjs', 'phantomjs.exe' )
        labeljs = os.path.join( public_dir, 'phantomjs', 'pdf.js' )

        pdfs = []

        for detail_id, item_code in details:
            http_url = 'http://%s/pdflayout/index?id=%s' % (request.headers.get( 'Host' ), detail_id)

            _name = '%s_%s%d' % (trim(item_code), dt.now().strftime( "%Y%m%d%H%M%S" ), random.randint( 1, 1000 ) )
            pdf_file = os.path.join( download_dir, '%s.pdf' % _name )

            cmd = '%s %s %s %s' % (phantomjs, labeljs, http_url, pdf_file)

            # print cmd

            sp = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT)

            while 1:
                if sp.poll() is not None:
                    #print 'exec command completed.'
                    break
                # else:
                #     line = sp.stdout.readline().strip()

            pdfs.append(pdf_file)

        pd_zip_file = os.path.join( download_dir, "%s_pdf_%s%d.zip" % (trim(header_no), dt.now().strftime( "%Y%m%d%H%M%S" ), random.randint( 1, 1000 ) ) )
        create_zip(pd_zip_file, pdfs)
        remove_files(pdfs)

        return pd_zip_file
    except:
        traceback.print_exc()
        return None

def create_zip(zipf, files):
    _zip = zipfile.ZipFile(zipf, 'w', zlib.DEFLATED)
    for f in files:
        if os.path.exists(f):
            _zip.write(os.path.abspath(f), os.path.basename(f))
    _zip.close()
    return zipf

def remove_files(files):
    for f in files:
        remove_file(f)

def remove_file(file):
    try:
        os.remove(file)
    except:
        pass

def trim(s):
    return ''.join(s.split())

def null_string_sizes(data):
    null_list = data.get('SIZE', {'values': []})['values']

    if not null_list:
        return ['']
    return null_list

def format_fibers(data, capitalize=False):
    fibers = {
        'en': [],
        'sp': []
    }

    for ff in data['FIBERS']['values']:
        if ff:
            if capitalize:
                fibers['en'].append('%s%% %s' % (ff['percent'], ff['english'].lower().capitalize()))
                fibers['sp'].append('%s%% %s' % (ff['percent'], ff['spanish'].lower().capitalize()))
            else:
                fibers['en'].append('%s%% %s' % (ff['percent'], ff['english']))
                fibers['sp'].append('%s%% %s' % (ff['percent'], ff['spanish']))
    # print fibers
    return fibers

def format_cares(data):
    cares = {
        'en': [],
        'sp': []
    }

    for cs in CARES:
        cc = data.get(cs, {'values': []})
        for c in cc['values']:
            # print '****', c
            cares['en'].append(c['english'])
            cares['sp'].append(c['spanish'])

    return cares

def format_coo(data):
    coos = {
        'en': [],
        'sp': []
    }

    for coo in data['CO']['values']:
        coos['en'].append(coo['english'])
        coos['sp'].append(coo['spanish'])

    return coos

def format_list(ll, method=None, s=''):
    if method:
        return s.join([getattr(l, method)() for l in ll if l])
    return s.join(ll)

def format_list2(ll):
    return [l.lower().capitalize() for l in ll if l]

def format_price(data):
    try:
        price = '$%.2f' % float(data['PRICE']['values'][0])
        return price
    except:
        return '$0.00'


text:
class BulkProcessor
  module Role
    # Role used by BulkProcessor::CSVProcessor (itself an abstract
    # implementation of the CSVProcessor role) to report on the results (or
    # failure) of processing a CSV file.
    class Handler
      def initialize(payload:, results:)
      end

      def complete!
      end

      def fail!(fatal_error)
      end
    end
  end
end


text:
package de.peeeq.wurstio.jassinterpreter.providers;

import de.peeeq.wurstscript.WLogger;
import de.peeeq.wurstscript.intermediatelang.*;
import de.peeeq.wurstscript.intermediatelang.interpreter.AbstractInterpreter;

import java.util.ArrayDeque;
import java.util.LinkedHashSet;
import java.util.Iterator;

public class GroupProvider extends Provider {

    private ArrayDeque<IlConstHandle> enumUnitStack = new ArrayDeque<>();

    public GroupProvider(AbstractInterpreter interpreter) {
        super(interpreter);
    }

    public IlConstHandle CreateGroup() {
        return new IlConstHandle(NameProvider.getRandomName("group"), new LinkedHashSet<>());
    }

    public void GroupClear(IlConstHandle group) {
        ((LinkedHashSet<IlConstHandle>) group.getObj()).clear();
    }

    public void GroupAddUnit(IlConstHandle group, IlConstHandle unit) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        groupList.add(unit);
    }

    public void GroupRemoveUnit(IlConstHandle group, IlConstHandle unit) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        groupList.remove(unit);
    }

    public ILconst FirstOfGroup(IlConstHandle group) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        if (groupList.isEmpty()) {
            WLogger.warning("Trying to get FoG of empty group");
            return ILconstNull.instance();
        }
        return groupList.iterator().next();
    }

    public void ForGroup(IlConstHandle group, ILconstFuncRef funcRef) {
        WLogger.trace("for group call");
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        groupList.forEach((IlConstHandle u) -> {
            enumUnitStack.push(u);
            WLogger.trace("for group call itr: " + funcRef.getFuncName());
            interpreter.runFuncRef(funcRef, null);
            enumUnitStack.pop();
        });
    }

    public IlConstHandle GetEnumUnit() {
        if (enumUnitStack.size() == 0 || enumUnitStack.peek() == null) {
            WLogger.warning("Calling GetEnumUnit() outside of callback");
        }
        return enumUnitStack.peek();
    }

    public void DestroyGroup(IlConstHandle group) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        groupList.clear();
    }

    public ILconstBool IsUnitInGroup(IlConstHandle unit, IlConstHandle group) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        return ILconstBool.instance(groupList.contains(unit));
    }

    public ILconstInt BlzGroupGetSize(IlConstHandle group) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        return ILconstInt.create(groupList.size());
    }

    public ILconst BlzGroupUnitAt(IlConstHandle group, ILconstInt index) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) group.getObj();
        ILconst elem = ILconstNull.instance();
        if(index.getVal() > 0 && index.getVal() < groupList.size()) {
            Iterator<IlConstHandle> it = groupList.iterator();
            elem = it.next();
            for(int i = 1; i <= index.getVal() && it.hasNext(); i++)
                elem = it.next();
            return elem;
        }
        else if(index.getVal() == 0)
            return FirstOfGroup(group);
        return elem;
    }

    public ILconstInt BlzGroupAddGroupFast(IlConstHandle group, IlConstHandle groupAdd) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) groupAdd.getObj();
        groupList.addAll((LinkedHashSet<IlConstHandle>) group.getObj());
        return ILconstInt.create(groupList.size());
    }

    public ILconstInt BlzGroupRemoveGroupFast(IlConstHandle group, IlConstHandle groupRm) {
        LinkedHashSet<IlConstHandle> groupList = (LinkedHashSet<IlConstHandle>) groupRm.getObj();
        groupList.removeAll((LinkedHashSet<IlConstHandle>) group.getObj());
        return ILconstInt.create(groupList.size());
    }
}


text:
<?php

namespace Bowerphp\Test\Command;

use Bowerphp\Factory\CommandFactory;
use PHPUnit\Framework\TestCase;

/**
 * @group functional
 */
class SearchCommandTest extends TestCase
{
    /**
     * @test
     */
    public function shouldExecute()
    {
        //when
        $commandTester = CommandFactory::tester('search', ['name' => 'smart']);

        //then
        $this->assertRegExp('/Search results/', $commandTester->getDisplay());
        $this->assertRegExp('/js-geo.git/', $commandTester->getDisplay());
    }

    /**
     * @test
     */
    public function shouldWriteNoResultWhenNoPackageFound()
    {
        //when
        $commandTester = CommandFactory::tester('search', ['name' => 'unexistant']);

        //then
        $this->assertRegExp('/No results/', $commandTester->getDisplay());
    }

    /**
     * @expectedException \RuntimeException
     * @expectedExceptionMessage Not enough arguments
     */
    public function shouldThrowExceptionWhenNoPackagePass()
    {
        //when
        CommandFactory::tester('search');
    }
}


text:
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/bookmarks/browser/url_index.h"

#include <iterator>

#include "base/containers/adapters.h"
#include "base/guid.h"
#include "components/bookmarks/browser/url_and_title.h"

namespace bookmarks {

namespace {

// Computes and aggregates into |*stats| metrics corresponding to a particular
// group of bookmarks with the same URL, listed in |*bookmarks_with_same_url|.
// The caller is responsible to guarantee that these provided bookmarks all
// share the same URL. Upon completion of this function, the state of
// |*bookmarks_with_same_url| is unspecified, because the implementation is free
// to modify its state desirable to avoid additional memory allocations on the
// calling site.
void AddStatsForBookmarksWithSameUrl(
    std::vector<const BookmarkNode*>* bookmarks_with_same_url,
    UrlIndex::Stats* stats) {
  if (bookmarks_with_same_url->size() <= 1)
    return;

  stats->duplicate_url_bookmark_count += bookmarks_with_same_url->size() - 1;

  // Sort only if there are 3 or more bookmarks. With exactly two (which is
  // believed to be a common case) the precise ordering is irrelevant for the
  // logic that follows.
  if (bookmarks_with_same_url->size() > 2) {
    std::sort(bookmarks_with_same_url->begin(), bookmarks_with_same_url->end(),
              [](const BookmarkNode* a, const BookmarkNode* b) {
                DCHECK_EQ(a->url(), b->url());
                if (a->GetTitle() != b->GetTitle())
                  return a->GetTitle() < b->GetTitle();
                return a->parent() < b->parent();
              });
  }

  size_t duplicate_title_count = 0;
  size_t duplicate_title_and_parent_count = 0;

  auto prev_i = bookmarks_with_same_url->begin();
  for (auto i = std::next(prev_i); i != bookmarks_with_same_url->end();
       ++i, ++prev_i) {
    DCHECK_EQ((*prev_i)->url(), (*i)->url());
    if ((*prev_i)->GetTitle() == (*i)->GetTitle()) {
      ++duplicate_title_count;
      if ((*prev_i)->parent() == (*i)->parent())
        ++duplicate_title_and_parent_count;
    }
  }

  DCHECK_LT(duplicate_title_count, bookmarks_with_same_url->size());
  DCHECK_LE(duplicate_title_and_parent_count, duplicate_title_count);

  stats->duplicate_url_and_title_bookmark_count += duplicate_title_count;
  stats->duplicate_url_and_title_and_parent_bookmark_count +=
      duplicate_title_and_parent_count;
}

}  // namespace

UrlIndex::UrlIndex(std::unique_ptr<BookmarkNode> root)
    : root_(std::move(root)) {
  base::AutoLock url_lock(url_lock_);
  AddImpl(root_.get());
}

void UrlIndex::Add(BookmarkNode* parent,
                   size_t index,
                   std::unique_ptr<BookmarkNode> node) {
  base::AutoLock url_lock(url_lock_);
  AddImpl(parent->Add(std::move(node), index));
}

std::unique_ptr<BookmarkNode> UrlIndex::Remove(BookmarkNode* node,
                                               std::set<GURL>* removed_urls) {
  base::AutoLock url_lock(url_lock_);
  RemoveImpl(node, removed_urls);
  BookmarkNode* parent = node->parent();
  return parent->Remove(static_cast<size_t>(parent->GetIndexOf(node)));
}

void UrlIndex::SetUrl(BookmarkNode* node, const GURL& url) {
  base::AutoLock url_lock(url_lock_);
  RemoveImpl(node, nullptr);
  node->set_url(url);
  AddImpl(node);
}

void UrlIndex::SetTitle(BookmarkNode* node, const std::u16string& title) {
  // Acquiring the lock is necessary to avoid races with
  // UrlIndex::GetBookmarks().
  base::AutoLock url_lock(url_lock_);
  node->SetTitle(title);
}

void UrlIndex::GetNodesWithIconUrl(const GURL& icon_url,
                                   std::set<const BookmarkNode*>* nodes) {
  base::AutoLock url_lock(url_lock_);
  for (const BookmarkNode* node : nodes_ordered_by_url_set_) {
    if (node->icon_url() && icon_url == *node->icon_url())
      nodes->insert(node);
  }
}

void UrlIndex::GetNodesByUrl(const GURL& url,
                             std::vector<const BookmarkNode*>* nodes) {
  base::AutoLock url_lock(url_lock_);
  BookmarkNode tmp_node(/*id=*/0, base::GUID::GenerateRandomV4(), url);
  auto i = nodes_ordered_by_url_set_.find(&tmp_node);
  while (i != nodes_ordered_by_url_set_.end() && (*i)->url() == url) {
    nodes->push_back(*i);
    ++i;
  }
}

bool UrlIndex::HasBookmarks() const {
  base::AutoLock url_lock(url_lock_);
  return !nodes_ordered_by_url_set_.empty();
}

UrlIndex::Stats UrlIndex::ComputeStats() const {
  base::AutoLock url_lock(url_lock_);
  UrlIndex::Stats stats;
  stats.total_url_bookmark_count = nodes_ordered_by_url_set_.size();

  if (stats.total_url_bookmark_count <= 1)
    return stats;

  std::vector<const BookmarkNode*> bookmarks_with_same_url;
  auto prev_i = nodes_ordered_by_url_set_.begin();
  for (auto i = std::next(prev_i); i != nodes_ordered_by_url_set_.end();
       ++i, ++prev_i) {
    if ((*prev_i)->url() != (*i)->url()) {
      AddStatsForBookmarksWithSameUrl(&bookmarks_with_same_url, &stats);
      bookmarks_with_same_url.clear();
    }

    bookmarks_with_same_url.push_back(*i);
  }

  AddStatsForBookmarksWithSameUrl(&bookmarks_with_same_url, &stats);
  return stats;
}

bool UrlIndex::IsBookmarked(const GURL& url) {
  base::AutoLock url_lock(url_lock_);
  return IsBookmarkedNoLock(url);
}

void UrlIndex::GetBookmarks(std::vector<UrlAndTitle>* bookmarks) {
  base::AutoLock url_lock(url_lock_);
  const GURL* last_url = nullptr;
  for (auto i = nodes_ordered_by_url_set_.begin();
       i != nodes_ordered_by_url_set_.end(); ++i) {
    const GURL* url = &((*i)->url());
    // Only add unique URLs.
    if (!last_url || *url != *last_url) {
      UrlAndTitle bookmark;
      bookmark.url = *url;
      bookmark.title = (*i)->GetTitle();
      bookmarks->push_back(bookmark);
    }
    last_url = url;
  }
}

UrlIndex::~UrlIndex() = default;

bool UrlIndex::IsBookmarkedNoLock(const GURL& url) {
  url_lock_.AssertAcquired();
  BookmarkNode tmp_node(/*id=*/0, base::GUID::GenerateRandomV4(), url);
  return (nodes_ordered_by_url_set_.find(&tmp_node) !=
          nodes_ordered_by_url_set_.end());
}

void UrlIndex::AddImpl(BookmarkNode* node) {
  url_lock_.AssertAcquired();
  if (node->is_url())
    nodes_ordered_by_url_set_.insert(node);
  for (const auto& child : node->children())
    AddImpl(child.get());
}

void UrlIndex::RemoveImpl(BookmarkNode* node, std::set<GURL>* removed_urls) {
  url_lock_.AssertAcquired();
  if (node->is_url()) {
    auto i = nodes_ordered_by_url_set_.find(node);
    DCHECK(i != nodes_ordered_by_url_set_.end());
    // i points to the first node with the URL, advance until we find the
    // node we're removing.
    while (*i != node)
      ++i;
    nodes_ordered_by_url_set_.erase(i);
    if (removed_urls && !IsBookmarkedNoLock(node->url()))
      removed_urls->insert(node->url());
  }
  for (const auto& child : base::Reversed(node->children()))
    RemoveImpl(child.get(), removed_urls);
}

}  // namespace bookmarks


text:
// Copyright (c) 2017-2021 Ubisoft Entertainment
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.Win32;

namespace Sharpmake.Generators.VisualStudio
{
    public partial class Pyproj : IProjectGenerator
    {
        internal class ItemGroups
        {
            internal CSproj.ItemGroups.ItemGroup<ProjectReference> ProjectReferences = new CSproj.ItemGroups.ItemGroup<ProjectReference>();

            internal string Resolve(Resolver resolver)
            {
                var writer = new StringWriter();
                writer.Write(ProjectReferences.Resolve(resolver));
                return writer.ToString();
            }

            internal class ProjectReference : CSproj.ItemGroups.ItemGroupItem, CSproj.IResolvable
            {
                public Guid Project;
                public string Name;
                public string Private;
                public bool? ReferenceOutputAssembly = null;

                public string Resolve(Resolver resolver)
                {
                    using (resolver.NewScopedParameter("include", Include))
                    using (resolver.NewScopedParameter("projectRefName", Name))
                    using (resolver.NewScopedParameter("projectGUID", Project.ToString("B").ToUpper()))
                    using (resolver.NewScopedParameter("private", Private))
                    using (resolver.NewScopedParameter("ReferenceOutputAssembly", ReferenceOutputAssembly))
                    {
                        var writer = new StringWriter();

                        writer.Write(Template.Project.ProjectReferenceBegin);
                        writer.Write(Template.Project.ProjectRefName);
                        writer.Write(Template.Project.ProjectGUID);
                        writer.Write(Template.Project.Private);
                        if (ReferenceOutputAssembly.HasValue)
                            writer.Write(Template.Project.ReferenceOutputAssembly);
                        writer.Write(Template.Project.ProjectReferenceEnd);
                        return resolver.Resolve(writer.ToString());
                    }
                }
            }
        }

        private PythonProject _project;
        private List<Project.Configuration> _projectConfigurationList;
        private Builder _builder;
        public const string ProjectExtension = ".pyproj";

        private void Write(string value, TextWriter writer, Resolver resolver)
        {
            writer.Write(resolver.Resolve(value));
        }

        public void Generate(Builder builder, Project project, List<Project.Configuration> configurations, string projectFile, List<string> generatedFiles, List<string> skipFiles)
        {
            _builder = builder;

            FileInfo fileInfo = new FileInfo(projectFile);
            string projectPath = fileInfo.Directory.FullName;
            string projectFileName = fileInfo.Name;
            bool updated;

            if (!(project is PythonProject))
                throw new ArgumentException("Project is not a PythonProject");

            string projectFileResult = Generate((PythonProject)project, configurations, projectPath, projectFileName, out updated);
            if (updated)
                generatedFiles.Add(projectFileResult);
            else
                skipFiles.Add(projectFileResult);

            _builder = null;
        }

        private string Generate(PythonProject project, List<Project.Configuration> unsortedConfigurations, string projectPath, string projectFile, out bool updated)
        {
            var itemGroups = new ItemGroups();

            // Need to sort by name and platform
            List<Project.Configuration> configurations = new List<Project.Configuration>();
            configurations.AddRange(unsortedConfigurations.OrderBy(conf => conf.Name + conf.Platform));
            string sourceRootPath = project.IsSourceFilesCaseSensitive ? Util.GetCapitalizedPath(project.SourceRootPath) : project.SourceRootPath;

            Resolver resolver = new Resolver();

            using (resolver.NewScopedParameter("guid", configurations.First().ProjectGuid))
            using (resolver.NewScopedParameter("projectHome", Util.PathGetRelative(projectPath, sourceRootPath)))
            using (resolver.NewScopedParameter("startupFile", project.StartupFile))
            using (resolver.NewScopedParameter("searchPath", project.SearchPaths.JoinStrings(";")))
            {
                _project = project;
                _projectConfigurationList = configurations;

                DevEnvRange devEnvRange = new DevEnvRange(unsortedConfigurations);
                bool needsPypatching = devEnvRange.MinDevEnv >= DevEnv.vs2017;

                if (!needsPypatching && (devEnvRange.MinDevEnv != devEnvRange.MaxDevEnv))
                {
                    Builder.Instance.LogWarningLine("There are mixed devEnvs for one project. VS2017 or higher Visual Studio solutions will require manual updates.");
                }

                MemoryStream memoryStream = new MemoryStream();
                StreamWriter writer = new StreamWriter(memoryStream);

                // xml begin header
                Write(Template.Project.ProjectBegin, writer, resolver);

                string defaultInterpreterRegisterKeyName = $@"Software\Microsoft\VisualStudio\{
                        devEnvRange.MinDevEnv.GetVisualVersionString()
                    }\PythonTools\Options\Interpreters";

                var defaultInterpreter = GetRegistryCurrentUserSubKeyValue(defaultInterpreterRegisterKeyName, "DefaultInterpreter", "{00000000-0000-0000-0000-000000000000}");
                var defaultInterpreterVersion = GetRegistryCurrentUserSubKeyValue(defaultInterpreterRegisterKeyName, "DefaultInterpreterVersion", "2.7");

                string currentInterpreterId = defaultInterpreter;
                string currentInterpreterVersion = defaultInterpreterVersion;
                string ptvsTargetsFile = $@"$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Python Tools\Microsoft.PythonTools.targets";

                // environments
                foreach (PythonEnvironment pyEnvironment in _project.Environments)
                {
                    if (pyEnvironment.IsActivated)
                    {
                        string interpreterRegisterKeyName =
                            $@"Software\Microsoft\VisualStudio\{
                                devEnvRange.MinDevEnv.GetVisualVersionString()
                            }\PythonTools\Interpreters\{{{pyEnvironment.Guid}}}";
                        string interpreterDescription = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Description", "");
                        if (interpreterDescription != string.Empty)
                        {
                            currentInterpreterId = $"{{{pyEnvironment.Guid}}}";
                            currentInterpreterVersion = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Version", currentInterpreterVersion);
                        }
                    }
                }

                // virtual environments
                foreach (PythonVirtualEnvironment virtualEnvironment in _project.VirtualEnvironments)
                {
                    if (virtualEnvironment.IsDefault)
                    {
                        string baseInterpreterRegisterKeyName =
                            $@"Software\Microsoft\VisualStudio\{
                                devEnvRange.MinDevEnv.GetVisualVersionString()
                            }\PythonTools\Interpreters\{{{virtualEnvironment.BaseInterpreterGuid}}}";
                        string baseInterpreterDescription = GetRegistryCurrentUserSubKeyValue(baseInterpreterRegisterKeyName, "Description", "");
                        if (baseInterpreterDescription != string.Empty)
                        {
                            currentInterpreterId = $"{{{virtualEnvironment.Guid}}}";
                            currentInterpreterVersion = GetRegistryCurrentUserSubKeyValue(baseInterpreterRegisterKeyName, "Version", currentInterpreterVersion);
                        }
                    }
                }

                // Project description
                if (needsPypatching)
                {
                    currentInterpreterId = $"MSBuild|debug|$(MSBuildProjectFullPath)";
                    ptvsTargetsFile = FileGeneratorUtilities.RemoveLineTag;
                }

                using (resolver.NewScopedParameter("interpreterId", currentInterpreterId))
                using (resolver.NewScopedParameter("interpreterVersion", currentInterpreterVersion))
                using (resolver.NewScopedParameter("ptvsTargetsFile", ptvsTargetsFile))
                {
                    Write(Template.Project.ProjectDescription, writer, resolver);
                }

                GenerateItems(writer, resolver);

                string baseGuid = FileGeneratorUtilities.RemoveLineTag;

                foreach (PythonVirtualEnvironment virtualEnvironment in _project.VirtualEnvironments)
                {
                    baseGuid = needsPypatching ? baseGuid : virtualEnvironment.BaseInterpreterGuid.ToString();
                    string pyVersion = string.IsNullOrEmpty(virtualEnvironment.Version) ? currentInterpreterVersion : virtualEnvironment.Version;

                    Write(Template.Project.ProjectItemGroupBegin, writer, resolver);
                    using (resolver.NewScopedParameter("name", virtualEnvironment.Name))
                    using (resolver.NewScopedParameter("version", pyVersion))
                    using (resolver.NewScopedParameter("basePath", virtualEnvironment.Path))
                    using (resolver.NewScopedParameter("baseGuid", baseGuid))
                    using (resolver.NewScopedParameter("guid", virtualEnvironment.Guid))
                    {
                        Write(Template.Project.VirtualEnvironmentInterpreter, writer, resolver);
                    }
                    Write(Template.Project.ProjectItemGroupEnd, writer, resolver);
                }

                Write(Template.Project.ProjectItemGroupBegin, writer, resolver);

                if (_project.Environments.Count > 0)
                {
                    foreach (PythonEnvironment pyEnvironment in _project.Environments)
                    {
                        // Verify if the interpreter exists in the register.
                        string interpreterRegisterKeyName =
                            $@"Software\Microsoft\VisualStudio\{
                                devEnvRange.MinDevEnv.GetVisualVersionString()
                            }\PythonTools\Interpreters\{{{pyEnvironment.Guid}}}";
                        string interpreterDescription = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Description", "");
                        if (interpreterDescription != string.Empty)
                        {
                            string interpreterVersion = GetRegistryCurrentUserSubKeyValue(interpreterRegisterKeyName, "Version", currentInterpreterVersion);
                            using (resolver.NewScopedParameter("guid", $"{{{pyEnvironment.Guid}}}"))
                            using (resolver.NewScopedParameter("version", interpreterVersion))
                            {
                                Write(Template.Project.InterpreterReference, writer, resolver);
                            }
                        }
                    }
                }
                else if (_project.VirtualEnvironments.Count == 0) // Set the default interpreter
                {
                    using (resolver.NewScopedParameter("guid", currentInterpreterId))
                    using (resolver.NewScopedParameter("version", currentInterpreterVersion))
                    {
                        Write(Template.Project.InterpreterReference, writer, resolver);
                    }
                }
                Write(Template.Project.ProjectItemGroupEnd, writer, resolver);

                // configuration general
                foreach (Project.Configuration conf in _projectConfigurationList)
                {
                    foreach (var dependencies in new[] { conf.ResolvedPublicDependencies, conf.DotNetPrivateDependencies.Select(x => x.Configuration) })
                    {
                        foreach (var dependency in dependencies)
                        {
                            string relativeToProjectFile = Util.PathGetRelative(sourceRootPath, dependency.ProjectFullFileNameWithExtension);
                            bool privateDependency = project.DependenciesCopyLocal.HasFlag(Project.DependenciesCopyLocalTypes.ProjectReferences);
                            conf.GetDependencySetting(dependency.Project.GetType());

                            itemGroups.ProjectReferences.Add(new ItemGroups.ProjectReference
                            {
                                Include = relativeToProjectFile,
                                Name = dependency.ProjectName,
                                Private = privateDependency ? "True" : "False",
                                Project = new Guid(dependency.ProjectGuid)
                            });
                        }
                    }
                }

                GenerateFolders(writer, resolver);

                // Import native Python Tools project
                if (needsPypatching)
                {
                    Write(Template.Project.ImportPythonTools, writer, resolver);
                }

                writer.Write(itemGroups.Resolve(resolver));

                Write(Template.Project.ProjectEnd, writer, resolver);

                // Write the project file
                writer.Flush();

                // remove all line that contain RemoveLineTag
                memoryStream = Util.RemoveLineTags(memoryStream, FileGeneratorUtilities.RemoveLineTag);
                memoryStream.Seek(0, SeekOrigin.Begin);

                FileInfo projectFileInfo = new FileInfo(projectPath + @"\" + projectFile + ProjectExtension);
                updated = _builder.Context.WriteGeneratedFile(project.GetType(), projectFileInfo, memoryStream);

                writer.Close();

                _project = null;

                return projectFileInfo.FullName;
            }
        }

        private void GenerateItems(StreamWriter writer, Resolver resolver)
        {
            Strings projectFiles = _project.GetSourceFilesForConfigurations(_projectConfigurationList);

            // Add source files
            ProjectDirectory rootDirectory = new ProjectDirectory(null, _project.SourceRootPath);
            foreach (string file in projectFiles)
            {
                string relativeFile = GetProperRelativePathToSourcePath(file);
                relativeFile = relativeFile.Trim('.', '\\', '/');

                string[] splitFile = relativeFile.Split('\\', '/');

                ProjectDirectory directory = rootDirectory;
                for (int i = 0; i < splitFile.Length - 1; ++i)
                {
                    directory = directory.GetSubDirectory(splitFile[i]);
                }

                directory.AddFile(file);
            }

            Write(Template.Project.ProjectItemGroupBegin, writer, resolver);
            foreach (ProjectDirectory subDirectory in rootDirectory.Directories)
                WriteProjectDirectory(writer, subDirectory, "    ", true);
            foreach (string file in rootDirectory.Files)
                WriteProjectFile(writer, file, "    ");

            Write(Template.Project.ProjectItemGroupEnd, writer, resolver);
        }

        private void GenerateFolders(StreamWriter writer, Resolver resolver)
        {
            Strings projectFiles = _project.GetSourceFilesForConfigurations(_projectConfigurationList);

            // Add source files
            ProjectDirectory rootDirectory = new ProjectDirectory(null, _project.SourceRootPath);
            foreach (string file in projectFiles)
            {
                string relativeFile = GetProperRelativePathToSourcePath(file);
                relativeFile = relativeFile.Trim('.', '\\', '/');

                string[] splitFile = relativeFile.Split('\\', '/');

                ProjectDirectory directory = rootDirectory;
                for (int i = 0; i < splitFile.Length - 1; ++i)
                {
                    directory = directory.GetSubDirectory(splitFile[i]);
                }

                directory.AddFile(file);
            }

            Write(Template.Project.ProjectItemGroupBegin, writer, resolver);
            foreach (ProjectDirectory subDirectory in rootDirectory.Directories)
                WriteProjectDirectory(writer, subDirectory, "    ", false);

            Write(Template.Project.ProjectItemGroupEnd, writer, resolver);
        }

        private void WriteProjectDirectory(StreamWriter writer, ProjectDirectory directory, string prefix, bool writeFiles)
        {
            if (writeFiles)
            {
                foreach (string filename in directory.Files)
                {
                    WriteProjectFile(writer, filename, prefix);
                }
            }
            else
            {
                writer.WriteLine(prefix + "<Folder Include=\"" + GetProperRelativePathToSourcePath(directory.Path) + "\" />");
            }

            foreach (ProjectDirectory subDirectory in directory.Directories)
            {
                WriteProjectDirectory(writer, subDirectory, prefix, writeFiles);
            }
        }

        private void WriteProjectFile(StreamWriter writer, string filename, string prefix)
        {
            string fileTag = (Path.GetExtension(filename) == ".py") ? "Compile" : "Content";
            writer.WriteLine(prefix + "<" + fileTag + " Include=\"" + GetProperRelativePathToSourcePath(filename) + "\" />");
        }

        private string GetProperRelativePathToSourcePath(string path)
        {
            return Util.PathGetRelative(_project.SourceRootPath, _project.IsSourceFilesCaseSensitive ? Util.GetCapitalizedPath(path) : path);
        }

        private static string GetRegistryCurrentUserSubKeyValue(string registrySubKey, string value, string fallbackValue)
        {
            string key = string.Empty;

            if (Util.GetExecutingPlatform().HasAnyFlag(Platform.win32 | Platform.win64))
            {
                using (RegistryKey subKey = Registry.CurrentUser.OpenSubKey(registrySubKey))
                    key = (string)subKey?.GetValue(value);
            }

            if (string.IsNullOrEmpty(key))
                key = fallbackValue;

            return key;
        }

        private class ProjectDirectory
        {
            public string Name;
            public string Path;
            public List<string> Files = new List<string>();
            public List<ProjectDirectory> Directories = new List<ProjectDirectory>();

            public ProjectDirectory(string name, string path)
            {
                Name = name;
                Path = path;
            }

            public ProjectDirectory GetSubDirectory(string name)
            {
                foreach (ProjectDirectory dir in Directories)
                {
                    if (dir.Name == name)
                        return dir;
                }
                ProjectDirectory newDir = new ProjectDirectory(name, Path + "\\" + name);
                Directories.Add(newDir);
                return newDir;
            }

            public void AddFile(string filename)
            {
                Files.Add(filename);
            }
        }
    }
}


text:
from swgpy.object import *

def create(kernel):
	result = Tangible()

	result.template = "object/tangible/ship/components/droid_interface/shared_ddi_qualdex_droid_interface_mk2.iff"
	result.attribute_template_id = 8
	result.stfName("space/space_item","ddi_qualdex_droid_interface_mk2")

	#### BEGIN MODIFICATIONS ####
	####  END MODIFICATIONS  ####

	return result