text:
using System;
using System.Configuration;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Web.Hosting;
using System.Web.Security;
using System.Xml.Linq;
using Microsoft.Xrm.Client;
using Microsoft.Xrm.Client.Services;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Xrm.Sdk.Query;

namespace Site.Areas.Setup
{
	public abstract class SetupManager
	{
		public abstract bool Exists();
		public abstract ConnectionStringSettings GetConnectionString();
		public abstract string GetWebsiteName();
		public abstract void Save(Uri organizationServiceUrl, AuthenticationProviderType authenticationType, string domain, string username, string password, Guid websiteId);
		public abstract bool Enabled();

		protected virtual void SaveWebsiteBinding(Guid websiteId)
		{
			using (var service = new OrganizationService(new CrmConnection(GetConnectionString())))
			{
				var website = new EntityReference("adx_website", websiteId);
				var siteName = GetSiteName();
				var virtualPath = HostingEnvironment.ApplicationVirtualPath ?? "/";

				var query = new QueryExpression("adx_websitebinding") { ColumnSet = new ColumnSet("adx_websiteid") };
				query.Criteria.AddCondition("statecode", ConditionOperator.Equal, 0);
				query.Criteria.AddCondition("adx_sitename", ConditionOperator.Equal, siteName);

				var pathFilter = query.Criteria.AddFilter(LogicalOperator.Or);
				if (!virtualPath.StartsWith("/")) virtualPath = "/" + virtualPath;
				pathFilter.AddCondition("adx_virtualpath", ConditionOperator.Equal, virtualPath);
				pathFilter.AddCondition("adx_virtualpath", ConditionOperator.Equal, virtualPath.Substring(1));
				if (virtualPath.Substring(1) == string.Empty)
				{
					pathFilter.AddCondition("adx_virtualpath", ConditionOperator.Null);
				}

				var bindings = service.RetrieveMultiple(query);

				if (bindings.Entities.Count == 0)
				{
					var websiteBinding = CreateWebsiteBinding(website, siteName, virtualPath);
					service.Create(websiteBinding);
				}
			}
		}

		private static Entity CreateWebsiteBinding(EntityReference websiteId, string siteName, string virtualPath)
		{
			var websiteBinding = new Entity("adx_websitebinding");
			websiteBinding.SetAttributeValue<string>("adx_name", StringExtensions.FormatWith("Binding: {0}{1}", siteName, virtualPath));
			websiteBinding.SetAttributeValue<EntityReference>("adx_websiteid", websiteId);
			websiteBinding.SetAttributeValue<string>("adx_sitename", siteName);
			websiteBinding.SetAttributeValue<string>("adx_virtualpath", virtualPath);

			return websiteBinding;
		}

		public static string GetSiteName()
		{
			string siteName = HostingEnvironment.SiteName;

			var match = SiteNameRegex.Match(siteName);
			return match.Success && match.Groups["site"].Success
				? match.Groups["site"].Value
				: siteName;
		}

		/// <summary>
		/// Regular expression to grep site name
		/// </summary>
		private static readonly Regex SiteNameRegex = new Regex(@"^.+_IN_\d+_(?<site>.+)$|^(?<site>[^\(\)]+)\(\d+\)$", RegexOptions.IgnoreCase);
	}

	internal class DefaultSetupManager : SetupManager
	{
		private DefaultSetupManager() { }

		public static SetupManager Create()
		{
			return new DefaultSetupManager();
		}

		public override void Save(Uri organizationServiceUrl, AuthenticationProviderType authenticationType, string domain, string username, string password, Guid websiteId)
		{
			var xml = new XElement("settings");
			xml.SetElementValue("organizationServiceUrl", organizationServiceUrl.OriginalString);
			xml.SetElementValue("authenticationType", authenticationType.ToString());
			xml.SetElementValue("domain", domain);
			xml.SetElementValue("username", username);
			xml.SetElementValue("password", Convert.ToBase64String(MachineKey.Protect(Encoding.UTF8.GetBytes(password), _machineKeyPurposes)));
			xml.Save(_settingsPath.Value);

			try
			{
				SaveWebsiteBinding(websiteId);
			}
			catch (Exception)
			{
				File.Delete(_settingsPath.Value);
			}
		}

		public override bool Exists()
		{
			return File.Exists(_settingsPath.Value);
		}

		public override ConnectionStringSettings GetConnectionString()
		{
			return Exists() ? _connectionString.Value : null;
		}

		public override string GetWebsiteName()
		{
			return Exists() ? _websiteName.Value : null;
		}

		public override bool Enabled()
		{
			return _isEnabled.Value;
		}

		private static readonly Lazy<string> _settingsPath = new Lazy<string>(GetSettingsPath);
		private static readonly Lazy<ConnectionStringSettings> _connectionString = new Lazy<ConnectionStringSettings>(InitConnectionString);
		private static readonly Lazy<string> _websiteName = new Lazy<string>(InitWebsiteName);
		private static readonly string[] _machineKeyPurposes = { "adxstudio", "setup" };
		private static readonly Lazy<bool> _isEnabled = new Lazy<bool>(CheckPortalConfigType);

		private static string GetSettingsPath()
		{
			var virtualPath = ConfigurationManager.AppSettings[typeof(SetupManager).FullName + ".SettingsPath"] ?? "~/App_Data/settings.xml";
			var settingsPath = HostingEnvironment.MapPath(virtualPath);
			var dataDirectory = Path.GetDirectoryName(settingsPath);

			if (!Directory.Exists(dataDirectory))
			{
				Directory.CreateDirectory(dataDirectory);
			}

			return settingsPath;
		}

		private static ConnectionStringSettings InitConnectionString()
		{
			var xml = XElement.Load(_settingsPath.Value);
			var organizationServiceUrl = GetUrl(xml, "organizationServiceUrl");
			var authenticationType = ToAuthType(GetEnum<AuthenticationProviderType>(xml, "authenticationType"));
			var domain = GetText(xml, "domain");
			var username = GetText(xml, "username");
			var password = Encoding.UTF8.GetString(MachineKey.Unprotect(Convert.FromBase64String(GetText(xml, "password")), _machineKeyPurposes));

			var connectionString = authenticationType == AuthenticationType.AD
				? StringExtensions.FormatWith("AuthType={0}; Url={1}; Username={2}; Password={3}; Domain={4};", authenticationType, organizationServiceUrl, username, password, domain)
				: StringExtensions.FormatWith("AuthType={0}; Url={1}; Username={2}; Password={3};", authenticationType, organizationServiceUrl, username, password);

			return new ConnectionStringSettings("Xrm", connectionString);
		}

		private static AuthenticationType ToAuthType(AuthenticationProviderType? apt)
		{
			if (apt == AuthenticationProviderType.ActiveDirectory) return AuthenticationType.AD;
			if (apt == AuthenticationProviderType.Federation) return AuthenticationType.IFD;
			if (apt == AuthenticationProviderType.OnlineFederation) return AuthenticationType.Office365;
			if (apt == AuthenticationProviderType.LiveId) return AuthenticationType.Live;
			return AuthenticationType.InvalidConnection;
		}

		private static string InitWebsiteName()
		{
			var xml = XElement.Load(_settingsPath.Value);
			return GetText(xml, "websiteName");
		}

		private static string GetText(XContainer xml, string tagName)
		{
			var element = xml.Element(tagName);
			return element != null ? element.Value : null;
		}

		private static Uri GetUrl(XContainer xml, string tagName)
		{
			var text = GetText(xml, tagName);
			return !string.IsNullOrWhiteSpace(text) ? new Uri(text) : null;
		}

		private static T? GetEnum<T>(XContainer xml, string tagName) where T : struct
		{
			var text = GetText(xml, tagName);
			return !string.IsNullOrWhiteSpace(text) ? StringExtensions.ToEnum<T>(text) as T? : null;
		}

		private enum PortalConfigType
		{
			OnLine,
			OnPrem,
			Azure
		}

		private static bool CheckPortalConfigType()
		{
			var portalConfigType = ConfigurationManager.AppSettings["PortalConfigType"];
			PortalConfigType result;
			if (!Enum.TryParse(portalConfigType, true, out result))
			{
				result = PortalConfigType.OnLine;
			}
			return  (result != PortalConfigType.OnLine);
		}

		/// <summary>
		///  Decision switch for the sort of Auth to login to CRM with
		/// </summary>
		public enum AuthenticationType
		{
			/// <summary>
			/// Active Directory Auth
			/// </summary>
			AD,
			/// <summary>
			/// Live Auth
			/// </summary>
			Live,
			/// <summary>
			/// SPLA Auth
			/// </summary>
			IFD,
			/// <summary>
			/// CLAIMS based Auth
			/// </summary>
			Claims,
			/// <summary>
			/// Office365 base login process
			/// </summary>
			Office365,
			/// <summary>
			/// OAuth based Auth
			/// </summary>
			OAuth,
			/// <summary>
			/// Invalid connection
			/// </summary>
			InvalidConnection = -1
		}
	}
}


text:
package setting

import (
	"time"

	"code.gitea.io/gitea/modules/git"
	"code.gitea.io/gitea/modules/log"

	version "github.com/mcuadros/go-version"
)

var (
	// Git settings
	Git = struct {
		Path                      string
		DisableDiffHighlight      bool
		MaxGitDiffLines           int
		MaxGitDiffLineCharacters  int
		MaxGitDiffFiles           int
		GCArgs                    []string `ini:"GC_ARGS" delim:" "`
		EnableAutoGitWireProtocol bool
		Timeout                   struct {
			Default int
			Migrate int
			Mirror  int
			Clone   int
			Pull    int
			GC      int `ini:"GC"`
		} `ini:"git.timeout"`
	}{
		DisableDiffHighlight:      false,
		MaxGitDiffLines:           1000,
		MaxGitDiffLineCharacters:  5000,
		MaxGitDiffFiles:           100,
		GCArgs:                    []string{},
		EnableAutoGitWireProtocol: true,
		Timeout: struct {
			Default int
			Migrate int
			Mirror  int
			Clone   int
			Pull    int
			GC      int `ini:"GC"`
		}{
			Default: int(git.DefaultCommandExecutionTimeout / time.Second),
			Migrate: 600,
			Mirror:  300,
			Clone:   300,
			Pull:    300,
			GC:      60,
		},
	}
)

func newGit() {
	if err := Cfg.Section("git").MapTo(&Git); err != nil {
		log.Fatal("Failed to map Git settings: %v", err)
	}
	if err := git.SetExecutablePath(Git.Path); err != nil {
		log.Fatal("Failed to initialize Git settings", err)
	}
	git.DefaultCommandExecutionTimeout = time.Duration(Git.Timeout.Default) * time.Second

	binVersion, err := git.BinVersion()
	if err != nil {
		log.Fatal("Error retrieving git version: %v", err)
	}

	if version.Compare(binVersion, "2.9", ">=") {
		// Explicitly disable credential helper, otherwise Git credentials might leak
		git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "credential.helper=")
	}

	var format = "Git Version: %s"
	var args = []interface{}{binVersion}
	// Since git wire protocol has been released from git v2.18
	if Git.EnableAutoGitWireProtocol && version.Compare(binVersion, "2.18", ">=") {
		git.GlobalCommandArgs = append(git.GlobalCommandArgs, "-c", "protocol.version=2")
		format += ", Wire Protocol %s Enabled"
		args = append(args, "Version 2") // for focus color
	}

	log.Info(format, args...)
}

redpajama_set_name: RedPajamaGithub


text:
<!DOCTYPE html>

		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
		<link rel="stylesheet" href="dashboard.css">

Logo Here

				Menu

Menu Item

Just a block of text

						Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus at commodo neque, in pellentesque massa. Quisque nibh nisi, eleifend at finibus quis, euismod in metus. Vestibulum sit amet ultricies enim. Nullam odio elit, sollicitudin non varius sit amet, pretium eu metus. Mauris lacinia feugiat odio, et bibendum ligula consectetur et. Proin aliquet eros vel pulvinar mattis. Cras a rutrum lorem, ut luctus dolor. Sed vel eros ut orci sagittis euismod. Curabitur gravida elit sit amet mi rhoncus malesuada.

						Nunc non massa vel odio tempor hendrerit ut id erat. Nunc auctor mattis sem in gravida. Vestibulum finibus vehicula purus nec gravida. Sed ac vehicula massa, id tristique tortor. Proin euismod, libero non consectetur consectetur, urna nulla dignissim urna, vel laoreet lectus lorem a dui. Proin ac est mauris. Cras et nisl id velit vulputate posuere. Cras convallis bibendum ligula non accumsan.

						Nunc auctor, velit a gravida iaculis, turpis augue egestas purus, sit amet laoreet eros arcu quis nisl. Suspendisse pellentesque in dolor nec rutrum. Nullam dictum imperdiet luctus. Sed et efficitur urna. Pellentesque volutpat sagittis nisi, sodales interdum nulla mattis a. Etiam vitae elit ac nibh tempor tristique. Nullam quis diam mi. Etiam pretium vel erat sed porta.

						Donec finibus ut nunc ut ultricies. Duis a felis dui. Nullam ante odio, commodo at posuere eget, tristique at orci. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas facilisis magna et libero sodales convallis. Fusce et tincidunt nisi. Nulla vitae egestas risus. Nunc rutrum nisl et posuere eleifend. Phasellus ac nisl ut orci suscipit tincidunt.

						Vivamus vitae molestie metus. Aenean ac nisi sed sem efficitur aliquam. Nunc varius justo sed ante blandit, ac luctus eros ullamcorper. Mauris lacus purus, cursus at nisi eu, ultricies luctus augue. Proin tristique tempor velit sit amet venenatis. Suspendisse potenti. Sed congue turpis sit amet risus facilisis, non laoreet nunc condimentum. Vivamus ornare orci bibendum nisl iaculis accumsan. Mauris volutpat fermentum enim, ac tristique metus vehicula a.

Another block of text

						Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus at commodo neque, in pellentesque massa. Quisque nibh nisi, eleifend at finibus quis, euismod in metus. Vestibulum sit amet ultricies enim. Nullam odio elit, sollicitudin non varius sit amet, pretium eu metus. Mauris lacinia feugiat odio, et bibendum ligula consectetur et. Proin aliquet eros vel pulvinar mattis. Cras a rutrum lorem, ut luctus dolor. Sed vel eros ut orci sagittis euismod. Curabitur gravida elit sit amet mi rhoncus malesuada.

						Nunc non massa vel odio tempor hendrerit ut id erat. Nunc auctor mattis sem in gravida. Vestibulum finibus vehicula purus nec gravida. Sed ac vehicula massa, id tristique tortor. Proin euismod, libero non consectetur consectetur, urna nulla dignissim urna, vel laoreet lectus lorem a dui. Proin ac est mauris. Cras et nisl id velit vulputate posuere. Cras convallis bibendum ligula non accumsan.

						Nunc auctor, velit a gravida iaculis, turpis augue egestas purus, sit amet laoreet eros arcu quis nisl. Suspendisse pellentesque in dolor nec rutrum. Nullam dictum imperdiet luctus. Sed et efficitur urna. Pellentesque volutpat sagittis nisi, sodales interdum nulla mattis a. Etiam vitae elit ac nibh tempor tristique. Nullam quis diam mi. Etiam pretium vel erat sed porta.

						Donec finibus ut nunc ut ultricies. Duis a felis dui. Nullam ante odio, commodo at posuere eget, tristique at orci. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Maecenas facilisis magna et libero sodales convallis. Fusce et tincidunt nisi. Nulla vitae egestas risus. Nunc rutrum nisl et posuere eleifend. Phasellus ac nisl ut orci suscipit tincidunt.

						Vivamus vitae molestie metus. Aenean ac nisi sed sem efficitur aliquam. Nunc varius justo sed ante blandit, ac luctus eros ullamcorper. Mauris lacus purus, cursus at nisi eu, ultricies luctus augue. Proin tristique tempor velit sit amet venenatis. Suspendisse potenti. Sed congue turpis sit amet risus facilisis, non laoreet nunc condimentum. Vivamus ornare orci bibendum nisl iaculis accumsan. Mauris volutpat fermentum enim, ac tristique metus vehicula a.

			        		Total records: {{::test.data.length | number: 0}}
			        		Displayed records: {{dataPage.length | number: 0}}

			            	Number
			            	Column One
			            	Column Two
							Column Three

			             {{::row.id}}
			             {{::row.column1}}
			             {{::row.column2}}
			             {{::row.longText}}.


text:
<?php

namespace AppBundle\Repository\Admin\Main;

use AppBundle\Entity\Main\User;
use AppBundle\Filter\Common\Main\UserFilter;
use AppBundle\Filter\Base\Filter;
use Doctrine\ORM\QueryBuilder;
use AppBundle\Repository\Base\BaseRepository;

class UserRepository extends BaseRepository {

	protected function buildOrderBy(QueryBuilder &$builder, Filter $filter) {
		$builder->addOrderBy('e.surname', 'ASC');
		$builder->addOrderBy('e.forename', 'ASC');
	}

	protected function getSelectFields(QueryBuilder &$builder, Filter $filter) {
		$fields = parent::getSelectFields($builder, $filter);

		$fields[] = 'e.email';
		$fields[] = 'e.username';
		$fields[] = 'e.surname';
		$fields[] = 'e.forename';
		$fields[] = 'e.pseudonym';

		return $fields;
	}

	protected function getWhere(QueryBuilder &$builder, Filter $filter) {
		$where = parent::getWhere($builder, $filter);
		/** @var UserFilter $filter */

		$this->addStringWhere($builder, $where, 'e.username', $filter->getUsername());
		$this->addStringWhere($builder, $where, 'e.surname', $filter->getSurname());
		$this->addStringWhere($builder, $where, 'e.forename', $filter->getForename());
		$this->addStringWhere($builder, $where, 'e.email', $filter->getEmail());

		return $where;
	}

	// ------------------------------
	//
	// ------------------------------
	protected function buildFilterOrderBy(QueryBuilder &$builder) {
		$builder->addOrderBy('e.surname', 'ASC');
		$builder->addOrderBy('e.forename', 'ASC');
	}

	protected function getFilterWhere(QueryBuilder &$builder) {
		$where = parent::getFilterWhere($builder);

		$expr = $builder->expr();

		$roles = $expr->orX();
		$roles->add($expr->like('e.roles', $expr->literal('%BENCHMARK%')));
		$roles->add($expr->like('e.roles', $expr->literal('%EDITOR%')));
		$roles->add($expr->like('e.roles', $expr->literal('%ADMIN%')));

		//TODO unlock when users are automatically added in registration form to proper role (BENCHMARK orEDITOR)
// 		$where->add($roles);

		return $where;
	}

	protected function getFilterSelectFields(QueryBuilder &$builder) {
		$fields = parent::getFilterSelectFields($builder);

		$fields[] = 'e.surname';
		$fields[] = 'e.forename';
		$fields[] = 'e.username';

		return $fields;
	}

	protected function getFilterItemKeyFields($item) {
		$fields = parent::getFilterItemKeyFields($item);

		$fields[] = $item['surname'];
		$fields[] = $item['forename'];
		$fields[] = '(' . $item['username'] . ')';

		return $fields;
	}

	protected function getEntityType() {
		return User::class;
	}
}


text:
module BetfairNg

	#  Declares the module for API interactions
	#
	module API

		#  Declares the module for Data types
		#
		module DataTypes

			#  Declares DeveloperApp
			#
			#  Describes developer/vendor specific application
			#
			# == Fields
			#  - app_name
			#  - app_id
			#  - app_versions
			#
			class DeveloperApp < Base

				#  The unique name of the application
				# @!attribute [w]
				#
				field :app_name, type: String, required: true

				#  A unique id of this application
				# @!attribute [w]
				#
				field :app_id, type: Fixnum, required: true

				#  The application versions (including application keys)
				# @!attribute [w]
				#
				field :app_versions, type: "BetfairNg::API::DataTypes::List", of: "BetfairNg::API::DataTypes::DeveloperAppVersion", required: true

			end
		end
	end
end


text:
__author__ = 'Ruslan Spivak <ruslan.spivak@gmail.com>'

from slimit import ast

class ECMAVisitor(object):

    def __init__(self):
        self.indent_level = 0

    def _make_indent(self):
        return ' ' * self.indent_level

    def visit(self, node):
        method = 'visit_%s' % node.__class__.__name__
        return getattr(self, method, self.generic_visit)(node)

    def generic_visit(self, node):
        return 'GEN: %r' % node

    def visit_Program(self, node):
        return '\n'.join(self.visit(child) for child in node)

    def visit_Block(self, node):
        s = '{\n'
        self.indent_level += 2
        s += '\n'.join(
            self._make_indent() + self.visit(child) for child in node)
        self.indent_level -= 2
        s += '\n' + self._make_indent() + '}'
        return s

    def visit_VarStatement(self, node):
        s = 'var %s;' % ', '.join(self.visit(child) for child in node)
        return s

    def visit_VarDecl(self, node):
        output = []
        output.append(self.visit(node.identifier))
        if node.initializer is not None:
            output.append(' = %s' % self.visit(node.initializer))
        return ''.join(output)

    def visit_Identifier(self, node):
        return node.value

    def visit_Assign(self, node):
        if node.op == ':':
            template = '%s%s %s'
        else:
            template = '%s %s %s'
        if getattr(node, '_parens', False):
            template = '(%s)' % template
        return template % (
            self.visit(node.left), node.op, self.visit(node.right))

    def visit_GetPropAssign(self, node):
        template = 'get %s() {\n%s\n%s}'
        if getattr(node, '_parens', False):
            template = '(%s)' % template
        self.indent_level += 2
        body = '\n'.join(
            (self._make_indent() + self.visit(el))
            for el in node.elements
            )
        self.indent_level -= 2
        tail = self._make_indent()
        return template % (self.visit(node.prop_name), body, tail)

    def visit_SetPropAssign(self, node):
        template = 'set %s(%s) {\n%s\n%s}'
        if getattr(node, '_parens', False):
            template = '(%s)' % template
        if len(node.parameters) > 1:
            raise SyntaxError(
                'Setter functions must have one argument: %s' % node)
        params = ','.join(self.visit(param) for param in node.parameters)
        self.indent_level += 2
        body = '\n'.join(
            (self._make_indent() + self.visit(el))
            for el in node.elements
            )
        self.indent_level -= 2
        tail = self._make_indent()
        return template % (self.visit(node.prop_name), params, body, tail)

    def visit_Number(self, node):
        return node.value

    def visit_Comma(self, node):
        s = '%s, %s' % (self.visit(node.left), self.visit(node.right))
        if getattr(node, '_parens', False):
            s = '(' + s + ')'
        return s

    def visit_EmptyStatement(self, node):
        return node.value

    def visit_If(self, node):
        s = 'if ('
        if node.predicate is not None:
            s += self.visit(node.predicate)
        s += ') '
        s += self.visit(node.consequent)
        if node.alternative is not None:
            s += ' else '
            s += self.visit(node.alternative)
        return s

    def visit_Boolean(self, node):
        return node.value

    def visit_For(self, node):
        s = 'for ('
        if node.init is not None:
            s += self.visit(node.init)
        if node.init is None:
            s += ' ; '
        elif isinstance(node.init, (ast.Assign, ast.Comma, ast.FunctionCall,
                                    ast.UnaryOp, ast.Identifier, ast.BinOp,
                                    ast.Conditional, ast.Regex, ast.NewExpr)):
            s += '; '
        else:
            s += ' '
        if node.cond is not None:
            s += self.visit(node.cond)
        s += '; '
        if node.count is not None:
            s += self.visit(node.count)
        s += ') ' + self.visit(node.statement)
        return s

    def visit_ForIn(self, node):
        if isinstance(node.item, ast.VarDecl):
            template = 'for (var %s in %s) '
        else:
            template = 'for (%s in %s) '
        s = template % (self.visit(node.item), self.visit(node.iterable))
        s += self.visit(node.statement)
        return s

    def visit_BinOp(self, node):
        if getattr(node, '_parens', False):
            template = '(%s %s %s)'
        else:
            template = '%s %s %s'
        return template % (
            self.visit(node.left), node.op, self.visit(node.right))

    def visit_UnaryOp(self, node):
        s = self.visit(node.value)
        if node.postfix:
            s += node.op
        elif node.op in ('delete', 'void', 'typeof'):
            s = '%s %s' % (node.op, s)
        else:
            s = '%s%s' % (node.op, s)
        if getattr(node, '_parens', False):
            s = '(%s)' % s
        return s

    def visit_ExprStatement(self, node):
        return '%s;' % self.visit(node.expr)

    def visit_DoWhile(self, node):
        s = 'do '
        s += self.visit(node.statement)
        s += ' while (%s);' % self.visit(node.predicate)
        return s

    def visit_While(self, node):
        s = 'while (%s) ' % self.visit(node.predicate)
        s += self.visit(node.statement)
        return s

    def visit_Null(self, node):
        return 'null'

    def visit_String(self, node):
        return node.value

    def visit_Continue(self, node):
        if node.identifier is not None:
            s = 'continue %s;' % self.visit_Identifier(node.identifier)
        else:
            s = 'continue;'
        return s

    def visit_Break(self, node):
        if node.identifier is not None:
            s = 'break %s;' % self.visit_Identifier(node.identifier)
        else:
            s = 'break;'
        return s

    def visit_Return(self, node):
        if node.expr is None:
            return 'return;'
        else:
            return 'return %s;' % self.visit(node.expr)

    def visit_With(self, node):
        s = 'with (%s) ' % self.visit(node.expr)
        s += self.visit(node.statement)
        return s

    def visit_Label(self, node):
        s = '%s: %s' % (
            self.visit(node.identifier), self.visit(node.statement))
        return s

    def visit_Switch(self, node):
        s = 'switch (%s) {\n' % self.visit(node.expr)
        self.indent_level += 2
        for case in node.cases:
            s += self._make_indent() + self.visit_Case(case)
        if node.default is not None:
            s += self.visit_Default(node.default)
        self.indent_level -= 2
        s += self._make_indent() + '}'
        return s

    def visit_Case(self, node):
        s = 'case %s:\n' % self.visit(node.expr)
        self.indent_level += 2
        elements = '\n'.join(self._make_indent() + self.visit(element)
                             for element in node.elements)
        if elements:
            s += elements + '\n'
        self.indent_level -= 2
        return s

    def visit_Default(self, node):
        s = self._make_indent() + 'default:\n'
        self.indent_level += 2
        s += '\n'.join(self._make_indent() + self.visit(element)
                       for element in node.elements)
        if node.elements is not None:
            s += '\n'
        self.indent_level -= 2
        return s

    def visit_Throw(self, node):
        s = 'throw %s;' % self.visit(node.expr)
        return s

    def visit_Debugger(self, node):
        return '%s;' % node.value

    def visit_Try(self, node):
        s = 'try '
        s += self.visit(node.statements)
        if node.catch is not None:
            s += ' ' + self.visit(node.catch)
        if node.fin is not None:
            s += ' ' + self.visit(node.fin)
        return s

    def visit_Catch(self, node):
        s = 'catch (%s) %s' % (
            self.visit(node.identifier), self.visit(node.elements))
        return s

    def visit_Finally(self, node):
        s = 'finally %s' % self.visit(node.elements)
        return s

    def visit_FuncDecl(self, node):
        self.indent_level += 2
        elements = '\n'.join(self._make_indent() + self.visit(element)
                             for element in node.elements)
        self.indent_level -= 2

        s = 'function %s(%s) {\n%s' % (
            self.visit(node.identifier),
            ', '.join(self.visit(param) for param in node.parameters),
            elements,
            )
        s += '\n' + self._make_indent() + '}'
        return s

    def visit_FuncExpr(self, node):
        self.indent_level += 2
        elements = '\n'.join(self._make_indent() + self.visit(element)
                             for element in node.elements)
        self.indent_level -= 2

        ident = node.identifier
        ident = '' if ident is None else ' %s' % self.visit(ident)

        header = 'function%s(%s)'
        if getattr(node, '_parens', False):
            header = '(' + header
        s = (header + ' {\n%s') % (
            ident,
            ', '.join(self.visit(param) for param in node.parameters),
            elements,
            )
        s += '\n' + self._make_indent() + '}'
        if getattr(node, '_parens', False):
            s += ')'
        return s

    def visit_Conditional(self, node):
        if getattr(node, '_parens', False):
            template = '(%s ? %s : %s)'
        else:
            template = '%s ? %s : %s'

        s = template % (
            self.visit(node.predicate),
            self.visit(node.consequent), self.visit(node.alternative))
        return s

    def visit_Regex(self, node):
        if getattr(node, '_parens', False):
            return '(%s)' % node.value
        else:
            return node.value

    def visit_NewExpr(self, node):
        s = 'new %s(%s)' % (
            self.visit(node.identifier),
            ', '.join(self.visit(arg) for arg in node.args)
            )
        return s

    def visit_DotAccessor(self, node):
        if getattr(node, '_parens', False):
            template = '(%s.%s)'
        else:
            template = '%s.%s'
        s = template % (self.visit(node.node), self.visit(node.identifier))
        return s

    def visit_BracketAccessor(self, node):
        s = '%s[%s]' % (self.visit(node.node), self.visit(node.expr))
        return s

    def visit_FunctionCall(self, node):
        s = '%s(%s)' % (self.visit(node.identifier),
                        ', '.join(self.visit(arg) for arg in node.args))
        if getattr(node, '_parens', False):
            s = '(' + s + ')'
        return s

    def visit_Object(self, node):
        s = '{\n'
        self.indent_level += 2
        s += ',\n'.join(self._make_indent() + self.visit(prop)
                        for prop in node.properties)
        self.indent_level -= 2
        if node.properties:
            s += '\n'
        s += self._make_indent() + '}'
        return s

    def visit_Array(self, node):
        s = '['
        length = len(node.items) - 1
        for index, item in enumerate(node.items):
            if isinstance(item, ast.Elision):
                s += ','
            elif index != length:
                s += self.visit(item) + ','
            else:
                s += self.visit(item)
        s += ']'
        return s

    def visit_This(self, node):
        return 'this'


text:
	<title>READ-ME | Marvin Framework</title>

Marvin Framework 1.5.1

	1. Support Marvin

	2. Using Marvin in your a application

	3. Compiling and running (command-line)

	4. Resources

	5. Discussion Group

	6. Subscribe

	7. Commercial Solutions

	8. License

1. Support Marvin

Suport us sharing the project with your friends and colleagues. Have you successfully used Marvin in a project?
Post a review. Visit our site and share it using the social media
panel on the top of the page. The more people we reach, more contributors we get!

2. Using Marvin in your a application

copy this folder 'marvin' to your project folder and add marvin_1.5.1.jar into your project
  library list

the folder organization, including subfolders 'framework' and 'plugins', must be preserved.

 DO NOT add plug-ins .jar to your library list. They are loaded dynamically.

3. Compiling and running (command-line)

Compiling: javac -cp .;./marvin/framework/marvin_1.5.1.jar YourApplication.java

Running: java -cp .;./marvin/framework/marvin_1.5.1.jar YourApplication

4. Resources

Tutorials

Examples

Plug-ins

Downloads (Samples and Project source code)

Youtube Channel

5. Discussion Group

Get involved in discussion! Marvin Discussion Group

6. Subscribe

Get informed about new releases subscribing our Freecode page!

7. Commercial Solutions

Are you looking for commercial solutions or support for your company? Contact
contact us.

8. License

Marvin is released under LGPL license. Basically it can be distributed by any means. Its
binary might be used for commercial purposes.