标签: module

使用模块进行TypeScript转换

如何使用导出的类转换变量的类型?比如这样:

GameManager.ts:

export class GameManager {}
Run Code Online (Sandbox Code Playgroud)

Player.ts:

private _manager: GameManager;
Run Code Online (Sandbox Code Playgroud)

当我使用a时/// <reference path="GameManager.ts" />,我得到一个错误,说GameManager超出范围或类似的东西.这是如何工作的?

casting module node.js typescript

0
推荐指数
1
解决办法
948
查看次数

Django说我的语法错了

基本上使用django并且它一直告诉我这段代码中存在语法错误:

from django.conf.urls import patterns, url

from venues import views

urlpatterns = patterns('',
    url(r'^$', views.index, name = 'index'),

    # ex /venues/3
    url(r'^(?P<venue_id>\d+)/$', views.detail, name='detail'),
    # ex: /venues/3/events
    url(r'^(?P<venue_id>\d+)/events/$', views.events, name='events')
)
Run Code Online (Sandbox Code Playgroud)

特别是它似乎在告诉我:

from venues import views
Run Code Online (Sandbox Code Playgroud)

行不正确.

但是我的场地/ views.py看起来像:

from django.http import HttpResponse

def index(request):
    return HttpResponse("Hello this is the home page!")

def detail(request, venue_id):
    return HttpResponse("You're looking at Venue %s.", % venue_id)

def events(request, venue_id):
    return HttpResponse("You're looking at events at venue %s.", % venue_id)
Run Code Online (Sandbox Code Playgroud)

所以文件存在并且似乎做得很好,直到我开始在urls.py中使用venue_id

哦,只是为了衡量我的主要urls.py看起来像:

from django.conf.urls …
Run Code Online (Sandbox Code Playgroud)

python django syntax module

0
推荐指数
1
解决办法
108
查看次数

在Python的模块中定义和使用类

我在模块中有模块Test.py和类测试.这是代码:

class test:

    SIZE = 100;
    tot = 0;

    def __init__(self, int1, int2):
        tot = int1 + int2;

    def getTot(self):
        return tot;

    def printIntegers(self):
        for i in range(0, 10):
            print(i);
Run Code Online (Sandbox Code Playgroud)

现在,在翻译我尝试:

>>> import Test
>>> t = test(1, 2);
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    t = test(1, 2);
NameError: name 'test' is not defined
Run Code Online (Sandbox Code Playgroud)

我哪里做错了?

python module class

0
推荐指数
1
解决办法
56
查看次数

找不到undefined的功能 - CommonJS模式

var revealed = function(){
   var a = [1,2,3];
   function abc(){
     return (a[0]*a[1])+a[2]);
   }

   return {
      name: 'revealed',
      abcfn: abc
   }

   module.exports = revealed;
}();
Run Code Online (Sandbox Code Playgroud)

如何将CommonJS模式与Revealing Module模式一起使用?当我尝试module.exports = revealed;并尝试将模块包含在某个地方来调用该函数时,它会引发错误说法function not found.

var module = require('module');
module.abc();
Run Code Online (Sandbox Code Playgroud)

无法调用未定义的方法.

javascript module node.js

0
推荐指数
1
解决办法
250
查看次数

如何构建Joomla扩展?

首先我想知道扩展插件模块之间有什么区别

然后我想知道如何开始这个?我必须拥有哪些工具和知识

什么是最好的武术?

joomla module

0
推荐指数
1
解决办法
119
查看次数

使用perl模块的当前工作目录版本

我正在尝试运行perl脚本并使其在当前工作目录中使用模块文件.我这样做是因为我最终需要在另一台机器上使用脚本和模块,而我无法控制安装了什么或哪些模块.我的问题是,我可以让它在某些机器上运行,但不能在其他机器上运行.

该脚本是:

ubuntu@machine-5:/tmp/pig-local$ cat test.pl
#!/usr/bin/perl -w -I ./Text
use Text::CSV_XS ;
print "Hello World\n"
Run Code Online (Sandbox Code Playgroud)

并在执行时我收到错误:

ubuntu@machine-5:/tmp/pig-local$ ./test.pl 
Can't locate loadable object for module Text::CSV_XS in @INC (@INC contains: ./Text  ./Text /home/ubuntu/perl5/lib/perl5/x86_64-linux-gnu-thread-multi /home/ubuntu/perl5/lib/perl5/x86_64-linux-g
nu-thread-multi /home/ubuntu/perl5/lib/perl5 /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/
lib/site_perl .) at ./test.pl line 2
Compilation failed in require at ./test.pl line 2.
BEGIN failed--compilation aborted at ./test.pl line 2.
Run Code Online (Sandbox Code Playgroud)

当前工作目录确实包含Text目录和CSV_XS.pm模块.我检查了md5sum文件,它与脚本工作的机器相同.

ubuntu@machine-5:/tmp/pig-local$ ls Text/
CSV_XS.pm
Run Code Online (Sandbox Code Playgroud)

我的操作系统是:

ubuntu@machine-5:/tmp/pig-local$ lsb_release -a
No …
Run Code Online (Sandbox Code Playgroud)

perl module

0
推荐指数
1
解决办法
835
查看次数

错误:RELAXNGV:RELAXNG_ERR_EXTRACONTENT:元素表单有额外的内容:表格

我要去开发人员工作报价模块.如果我们选择相关部门,我们可以选择工人为他们提供工作(在种植业).尝试比较午餐模块(午餐订单表格),但我得到了这个错误.(OpenERP ver 7)

这是我的view.xml

    <record model="ir.ui.view" id="bpl_work_offer_form">
        <field name="name">bpl.work.offer.form</field>
        <field name="model">bpl.work.offer</field>
        <field name="arch" type="xml">
            <form string='bpl_work_offer'>
                <sheet>
                    <group>
                        <group>
                            <field name='user_id' />
                        </group>
                        <group>
                            <field name='date_of_offer' />
                        </group>
                    </group>
                    <div name="Worker Selection"></div>
                    <separator string='Select workers' />
                    <field name='selected_workers_line_ids' nolabel='1'>
                        <tree string='List' editable='bottom'>
                            <field name='worker_id' />
                            <field name='is_selected' />
                        </tree>
                    </field>
                    <group class='oe_subtotal_footer oe_right'>
                        <field name='total_workers' />
                    </group>
                    <br />
                    <br />
                </sheet>
            </form>
        </field>
    </record>
Run Code Online (Sandbox Code Playgroud)

这是我的模特课

class bpl_work_offer(osv.osv):
    _name = "bpl.work.offer"
    _description = "BPL Work Offer"
    _columns = {
        'user_id': …
Run Code Online (Sandbox Code Playgroud)

python xml module openerp

0
推荐指数
1
解决办法
2105
查看次数

为什么我不能在nodejs模块中创建一个闭包

我正在尝试制作以下nodejs模块:

exports.method = function () {      
  var init = true;

  return function (args) {
     console.dir(args);
  };
};
Run Code Online (Sandbox Code Playgroud)

但是当我调用这个方法时,我没有收到控制台消息:

require('./module.js').method({test: 1});
Run Code Online (Sandbox Code Playgroud)

它返回一个函数而不是调用它.

module node.js requirejs

0
推荐指数
1
解决办法
856
查看次数

Python:没有类的模块中的持久变量?

编辑:这是我尝试失败的实际代码:

sounds.py

import audio
import time

localAudioPlayer = None

def Play(soundString, wait=True):
    if (localAudioPlayer != None): 
        localAudioPlayer.stop()
    localAudioPlayer = audio.stream("sound/%s.ogg" % soundString)
    localAudioPlayer.play()
    if (wait == True):
        while (localAudioPlayer.playing == True):
            time.sleep(0.1)
    return
Run Code Online (Sandbox Code Playgroud)

"audio"是我写的一个完整的库(在带有init的文件夹中),允许音频播放.

这里的想法是,如果在声音已经播放的同时调用Play(),则应停止该声音.

我没有我的代码设置,我可以实例化audio.stream()对象,而无需播放实际文件,因此预先初始化它并不是一个好主意.

我尝试了与原始示例类似的代码(我设置stuffLocalVar = None然后在函数中测试它为None)并且它工作正常.所以这是特定代码的特定内容.

当我在Python控制台上"导入声音"并尝试直接执行Play()时,我得到了相同的回溯.

追溯:

>>> sounds2.Play("file.ogg")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "sounds2.py", line 7, in Play
    if (localAudioPlayer != None): 
UnboundLocalError: local variable 'localAudioPlayer' referenced before assignment
Run Code Online (Sandbox Code Playgroud)

原版的

我不确定这个设置的正确术语,所以让我举个简短的例子:

mainApp.py:

import stuff
print stuff.do() …
Run Code Online (Sandbox Code Playgroud)

python module

0
推荐指数
1
解决办法
2597
查看次数

Perl不包括自定义模块

我最近不得不从一个共享帐户转移到一个VPS,自从我进入VPS后,我无法获得一些我不会再写的Perl脚本了.

主脚本如下所示:

#!/usr/bin/perl

BEGIN{ push @INC, '../'; }

use CGI qw/:standard *div *form *script/;  
use Vamp::Config qw/:site/;
use Vamp::Users;
use Vamp::Utils;
use Vamp::HTML;
use strict;
use warnings;
Run Code Online (Sandbox Code Playgroud)

根据我对Perl的有限知识,我可以说它正在尝试使用一些自定义Perl模块(配置,用户,实用程序和HTML).但是,这里有一些东西不允许使用它们.

文件夹结构如下所示:

  • 登录/ index.pl
  • 鞋面/ Config.pm

这就是其中一个模块的编写方式:

package Vamp::Config;

BEGIN{ push @INC, '../' }

use Exporter;
use strict;
use warnings;

our @ISA = ("Exporter");
our @EXPORT_OK = qw/%DB $HOME_URL $ADMIN_URL $SITE_ROOT/;
our %EXPORT_TAGS = (
    database => [qw/%DB/],
    site    => [qw/$HOME_URL $SITE_ROOT/],
    admin   => [qw/$ADMIN_URL/]
);

our %DB = (
    LIVE    => { …
Run Code Online (Sandbox Code Playgroud)

perl module perl-module

0
推荐指数
1
解决办法
117
查看次数